I have this following query :
IF NOT EXISTS (SELECT 1
FROM sysobjects
WHERE id = Object_id('tempdb..TEMP_THETH_DETAILS'))
EXECUTE (
'CREATE TABLE tempdb..TEMP_THETH_DETAILS( THETH_ID NUMERIC(5) NOT NULL, LANGUAGE VARCHAR(3) DEFAULT ''EN'' NOT NULL)'
)
GO
The problem is the checking, it seems tempdb doesnt take on consideration if not exist, maybe because the table was create in the tempdb.
So my question is there a way I can check if the temporary table exists or not ?
Try this:
IF object_id('tempdb..TEMP_THETH_DETAILS') is null
begin
EXECUTE
(
'CREATE TABLE tempdb..TEMP_THETH_DETAILS
( THETH_ID NUMERIC(5) NOT NULL,
LANGUAGE VARCHAR(3) DEFAULT ''EN'' NOT NULL
)'
)
end
go
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With