Format SQL, Apply Layout isn't working on CREATE SCHEMA following an IF NOT EXISTS
EnrightMcC
Posts: 14 Bronze 2
in SQL Prompt
Why can't this code be formatted (Ctrl K+Y)?
***
SQL Prompt Version 9.4.6807
Replacing the CREATE SCHEMA works, Using only the CREATE SCHEMA works; but when I have them together, it doesn't work. I've tried BEGIN/END blocks; and everything else I could think of. What's wrong?
***
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'staging')
CREATE SCHEMA staging;
****
Error in 'apply layout (format sql)'
Script parsing errors (2):
Ln:2 Col: 2 - incorrect syntax near CREATE
Ln:2 Col: 9 - incorrect syntax near SCHEMA
Error in 'apply layout (format sql)'
Script parsing errors (2):
Ln:2 Col: 2 - incorrect syntax near CREATE
Ln:2 Col: 9 - incorrect syntax near SCHEMA
SQL Prompt Version 9.4.6807
Replacing the CREATE SCHEMA works, Using only the CREATE SCHEMA works; but when I have them together, it doesn't work. I've tried BEGIN/END blocks; and everything else I could think of. What's wrong?
Tagged:
Answers
I suspect it's because the CREATE SCHEMA statement needs to be the only statement in the batch. SSMS shows an error on that code for me as well, even with the BEGIN and END block.
I'm curious, does that code execute for you?
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
Thanks,
EnrightMcC