Friday, March 5, 2010

[Code] IF EXISTS table check

Because I keep coming over here to find the snippet...

if object_id('tempdb..##temptablename') is not null
drop table ##temptablename
CREATE TABLE ##temptablename (id INT IDENTITY, filelist VARCHAR(255))


or


SELECT * FROM tablename.dbo.sysobjects
WHERE id = OBJECT_ID(N'tablename_goes_here')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1

No comments: