Create or Replace

Blog series: SQL Server Connect Items

How many times have you been forced to change a “CREATE” statement to “ALTER” because “There is already an object…”:

Msg 2714, Level 16, State 3, Procedure XXX, Line 1 There is already an object named XXX in the database.
Msg 2714, Level 16, State 3, Procedure XXX, Line 1 There is already an object named XXX in the database.

And then you need to change it back to “CREATE” in the script, or else it won’t work when deploying. This will happen if you try to issue a “ALTER” statement on a object that does not exist:

(more…)

Continue ReadingCreate or Replace