How to check if Exists table in sql server

We can use the sys.Tables catalog view to check the existence of the Table.
Here in the below script we are checking the existence of the table Country.

Example:
IF EXISTS(SELECT 1 FROM sys.Tables 
          WHERE  Name = N'country' AND Type = N'U')
BEGIN

  PRINT 'Table Exists'
END
else
begin 
  PRINT 'Table Not Exists'
End
Result:

Post a Comment

0 Comments