General information
Forum:
Microsoft SQL Server
>I am creating some #temp temp tables conditionally. I am doing a insert into #mytemptable, which creates the table. How can I check if the table exists. With a regular table I can do the statement:
> if exists (select from dbo.sysobjects...)
>
>but this doesn't seem to work for a #temp table. HOw can I find out if a given temp table already exists?
>
>TIA
IF object_id(tempdb..#tablename) IS NOT NULL
PRINT 'The table exists.'
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only