Is it possible to make SQLCMD Mode 'Sticky'

2019-02-05 18:15发布

问题:

I have a database project in Visual Studio 2013, with a post deployment script that uses SQLCMD mode.

The problem I am having is that the project defaults to non-SQLCMD mode every time the project is opened. This means that every time the project is opened, the Error List will be flooded with errors like "Incorrect syntax near ':'." until the developer opens the deployment script and clicks the SQLCMD Mode button.

Is there a way to default to keeping SQLCMD Mode on so developers don't have to do this each time they open the project?

回答1:

Had to dig a little for this one:

Go to the Tools|Options menu, then expand to SQL Server Tools, Transact-SQL editor, Query Execution. There's a setting in there to click that says "By default, open new queries in SQLCMD mode".

However, this shouldn't throw any errors/warnings unless you have that particular script open unless there's something new in VS2013 that changes that behavior.

This looks like a local option so would need to be set for each developer.