Format SQL Error
Superz
Posts: 3 New member
I don't know if this is intended or something else, but when I have a script and I just want to select one of the many statements to format it I get an error pertaining to code outside of the selected code. I don't want to validate the whole script at that point. I just want to format the code within the selected code. Is there any way around this or could this possibly be a bug?
SQL Prompt version 9.2.1.5713
SSMS v17.7
SQL Prompt version 9.2.1.5713
SSMS v17.7
Tagged:
Answers
Can you disable formatting for blocks of code: https://documentation.red-gate.com/sp9/formatting-your-code
If problem persists, can you share a sample script?
Thanks.
Tianjiao Li | Redgate Software
Have you visited our Help Center?
First off it isn't that I don't know how to use SQL format. We actually use it all the time for formatting code to standardize it before it gets committing to our code repository. But maybe there is something in the settings that I'm not seeing.
My problem is that I when I try to format just a small piece of a code that is among lot of other code, which might not be error free, I get an error when formatting the small piece of code that I want to format. For example, when writing code for SSIS packages I write the code in SSMS first and then copy and paste it into Visual Studio (VS). Before I copy the code into VS I like to format it. In this case there can be lots of other code in this script file because this one script file can be used many times over for research, testing, and for scripts for other pieces of my SSIS package. It’s a scratch pad or playground essentially and some of the other code can be broken. I don’t want to go through a whole file and comment out or fix those other pieces of code just to get one chunk of code formatted.
In my example below the code that I want to format is just below the first comment and before the second comment. If I highlight that and do the SQL format I get an error because of the error below the second comment.