подскажите, ms sql - в динамике собираю и хочу выполнить
USE DatabaseName
GO
DBCC SHRINKFILE (N'DatabaseName_log' , 0, TRUNCATEONLY)
ругается "Incorrect syntax near 'GO'."
перевод каретки не помог
declare cur cursor fast_forward for
select 'USE ' + quotename('master')+ ';exec(''ALTER DATABASE ' + quotename(db.[name]) + ' set COMPATIBILITY_LEVEL = 140'')'
from sys.databases as db
where db.[name] not in ('master', 'model', 'msdb', 'tempdb')
and [compatibility_level] < 140
order by db.[name];
open cur;
fetch next from cur into @cmd;
while @
@fetch_status = 0
begin
begin try
exec(@cmd);
end try
begin catch
print @cmd;
end catch;
fetch next from cur into @cmd;
end;
close cur;
deallocate cur;