Wednesday, 19 August 2015

Check a table exists or not in database in SQL

IF OBJECT_ID (N'mytablename', N'U') IS NOT NULL
   SELECT 1 AS val  
ELSE
    SELECT 0 AS val;

No comments:

Post a Comment