SQL

how to check table exists in SQL Server?

how to check table exists in SQL Server? , someone asked me to explain?
SQL

Best way to use an INFORMATION_SCHEMA view. These views are most standard across the plateform.

To check if a table exists use:

IF (EXISTS (SELECT * 
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'UserLogin'))
BEGIN
--Do Stuff
print 'hello'
END


Output:

hello

Post your comments / questions