Write each statement in a single line or add a delimiter (default ;
) at the end of each statement:
if exists (select 1 from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F') where r.fkeyid = object_id('TABLE1') and o.name = CONSTRAINT1')
alter table TABLE1 drop constraint CONSTRAINT1
For completeness, because the code explain it best:
The magic is done by this code in ResourceDatabasePopulator
: Line 171..178
String delimiter = this.separator;
if (delimiter == null) {
delimiter = DEFAULT_STATEMENT_SEPARATOR; // ";"
if (!containsSqlScriptDelimiters(script, delimiter)) {
delimiter = "\n";
}
}
splitSqlScript(script, delimiter, statements);