TaoK / PoorMansTSqlFormatter

A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
GNU Affero General Public License v3.0
968 stars 268 forks source link

sqlcmd Commands like ":r filename.sql" or ":setvar name value" lead to parsing errors #92

Open ralfkret opened 11 years ago

ralfkret commented 11 years ago

Hi,

so not actually part of the SQL language, I use sqlcmd commands like ":r" and others. Unfortunately SqlFormatter does not recognize those and produces parsing errors.

It would be great, if there where an option that would allow me to format files that contain those commands by just ignoring lines that start with a ":".

For documentation on the sqlcmd commands go to http://msdn.microsoft.com/en-us/library/ms165702%28v=sql.105%29.aspx.

Kind Regards Ralf

TaoK commented 11 years ago

Hi Ralf, these look like host variables in DB2 or parameters in NexusDB - they should work in the current checked-in code (as of issue #81), but I haven't got around to packaging a new release in a while; I'll certainly update this when it gets published! Thanks, Tao

TaoK commented 11 years ago

Paul made the same request

TaoK commented 11 years ago

NOTE: these are NOT the same ad DB2 host variables because the initial colon must be at the start of the line, and normal T-SQL parsing rules are completely suspended for the entire line. This requirement actually CONFLICTS with DB2 host variable support, although the nature of the conflict (when there is a variable at the start of the line) makes me think SqlCMD mode will have to take priority.