I am completely at a dead end. I have the following block:
IF NOT EXISTS(SELECT * FROM sys.schemas WHERE name = 'Test') BEGIN CREATE SCHEMA Test; END;
If I run this against our SQL Server 2008, I get "Msg 156, Level 15, State 1, Line 3: The syntax is incorrect next to the keyword" SCHEMA ", but if I run only the CREATE SCHEMA
command, this works.
In addition, this works:
IF NOT EXISTS(SELECT * FROM sys.schemas WHERE name = 'Test') BEGIN PRINT 'CREATE GOES HERE'; END;
What am I doing wrong?
source share