Existence of Table in Database

How to Check Existence of Table in Database


In SQL Server we can check whether table exist in database or not by using following SQL code snippet. 


IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'YOUR_TABLE_NAME') AND type in (N'U'))
BEGIN
  --Your Code Here If table is present.                           
END
ELSE
BEGIN
   --Your Code Here If table not exist.
END

Comments

Post a Comment

Popular posts from this blog

SaveSetting and GetSetting in C#