How to check if an tempory table already exists 
Author Message
 How to check if an tempory table already exists
I would like to create a tempory table, only if one does
not exist already, how can I check if a particular table
exits?

"If exists (Select * from #table)
Begin
 ....
End "

Does not work.



Fri, 24 Dec 2004 23:59:09 GMT
 How to check if an tempory table already exists

IF EXISTS(SELECT * FROM tempdb.dbo.sysobjects
        WHERE name LIKE '#temptable%')
    PRINT '#temptable Exists'
ELSE
    PRINT '#temptable Does Not Exist'

- Anith


Quote:
> I would like to create a tempory table, only if one does
> not exist already, how can I check if a particular table
> exits?

> "If exists (Select * from #table)
> Begin
>  ....
> End "

> Does not work.



Sat, 25 Dec 2004 00:18:19 GMT
 How to check if an tempory table already exists
if object_id('tempdb..#tmp','u') is not null
print 'not exists'
else
print 'exists'

--
-oj
Rac v2.1 coming soon
http://www.rac4sql.net


Quote:
> I would like to create a tempory table, only if one does
> not exist already, how can I check if a particular table
> exits?

> "If exists (Select * from #table)
> Begin
>  ....
> End "

> Does not work.



Sat, 25 Dec 2004 02:19:22 GMT
 How to check if an tempory table already exists
oj -

I guess you have the NOT NULL instead of NULL.
No big deal though..

- Anith


Quote:
> if object_id('tempdb..#tmp','u') is not null
> print 'not exists'
> else
> print 'exists'

> --
> -oj
> Rac v2.1 coming soon
> http://www.rac4sql.net



> > I would like to create a tempory table, only if one does
> > not exist already, how can I check if a particular table
> > exits?

> > "If exists (Select * from #table)
> > Begin
> >  ....
> > End "

> > Does not work.



Sat, 25 Dec 2004 02:27:52 GMT
 How to check if an tempory table already exists
hahahhaha...good catch! tks.

--
-oj


Quote:
> oj -

> I guess you have the NOT NULL instead of NULL.
> No big deal though..

> - Anith



Sat, 25 Dec 2004 02:34:56 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. check if table already exists??

2. Checking if a #temp1 table exists already

3. How to check if a table already exists

4. vb: check if table already exists??

5. Checking if a Global Variables already exists

6. Check if temp. SP already exists

7. Check if cursor already exists.

8. How to check if Temp SP already exist

9. how to check if a cursor already exists...

10. Check if a file already exists

11. Temporary Table already exists

12. How to find out if a table already exists with PL/SQL


 
Powered by phpBB® Forum Software