Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Object

Author  Topic 

pravin14u
Posting Yak Master

246 Posts

Posted - 2006-08-18 : 06:21:51
how do i check for the existence of an object(Ex: a table) in my database?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-18 : 06:33:50
select * from sysobjects

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2006-08-18 : 06:33:52
i think this is to do with something like:
if exists(select ... from sysobjects where ...)
hope this guides you properly.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-18 : 07:16:13
[code]if objectproperty(object_id('dbo.MyTable'),'IsUserTable') = 1
begin .. do something if it exists ... end[/code]

CODO ERGO SUM
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-08-18 : 09:03:07
quote:
select * from sysobjects


Thats not funny

For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-18 : 11:49:41
or make use of Information_schema views

If exists(Select * from Information_schema.tables where table_name='name')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -