I would like this to be the ultimate discussion on how to check if a table exists in SQL Server 2000/2005 using SQL Statements.
When you Google for the answer, you g
You can use below code
IF (OBJECT_ID('TableName') IS NOT NULL ) BEGIN PRINT 'Table Exists' END ELSE BEGIN PRINT 'Table NOT Exists' END
Or
IF (EXISTS (SELECT * FROM sys.tables WHERE [name] = 'TableName')) BEGIN PRINT 'Table Exists' END ELSE BEGIN PRINT 'Table NOT Exists' END