Tuesday, July 4, 2017

SQL Server IF condition to check table exists in the database


-- If 'tmp_processedLogs' table doesn't exists, then create it.
IF NOT EXISTS (SELECT * FROM sysobjects WHERE NAME = 'tmp_processedLogs' AND xtype='U')
CREATE TABLE tmp_processedLogs(LogFileName VARCHAR(MAX),Message VARCHAR(MAX),ProcessedOn DATETIME);

No comments:
Write comments
Recommended Posts × +