August 2011 Entries

DDL 'IF not Exists" conditions to make SQL scripts re-runnable

As a part of continuous integration we are using deployment of database scripts, which makes very important to make the scripts re-runnable. Some checks for DDL elements are not obvious, and I decided to put hem in one place.Most answers were found on StackOverflow --Column does not exists if NOT Exists(select * from sys.columns where Name = N'CreatedDate' and Object_ID = Object_ID(N'MyTableName')) --Check if primary key does not exists IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLE_CO... ......

«August»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910