I am using a Database Update Script which works based on versions. It has a section for each version following this basic format:
if (SELECT max(version) FROM DatabaseVersion) < x
BEGIN
/*CODE*/
INSERT INTO DatabaseVersion ....... (Current Version Number, Description of Change)
END
Just wrap your code that does not compile in EXEC ()
:
if (SELECT max(version) FROM DatabaseVersion) < x
exec('INSERT INTO DatabaseVersion ....... (Current Version Number, Description of Change)')
Here is a picture where exec has executed more than 128 characters of code:
And here is the link to the documentation: EXECUTE-Transact-SQL