
How to check if a table already exists
Be aware that Object_ID() only returns a status whether or not an object
exists.
e.g.
create proc myTable
as
select 1
go
--false info
if object_id('myTable') is not null
print 'False: myTable exists'
--using undoc second parameter
if object_id('myTable','U') is not null
print 'myTable exists'
go
drop proc myTable
go
--
-oj
Rac v2.2 & QALite
http://www.rac4sql.net
Quote:
> Hello All,
> Is there any system stored procedure which can tell if a table already
> exists in the db?
> I know how to do this by a query ... but that makes code unreadable.
> regards,
> Abhishek.