Search code examples
database-project

Create roll-on script using Database Project that does not require SqlCmd


When using database projects, compare, and then Generate Script then the generated scripts is default for SqlCmd. E.g. it generates a row like:

/*
Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
To re-enable the script after enabling SQLCMD mode, execute the following:
SET NOEXEC OFF; 
*/
:setvar __IsSqlCmdEnabled "True"

Is it possible to generate scripts in the Database Project that just generates the stuff that can be executed via SQL Server Management Studio?

(I use Visual Studio 2022)


Solution

  • I did not quite understand your question, but you helped me solve a problem. I was getting SQL80001 errors when editing my *.sql files. To suppress the errors, I needed to set the following Visual Studio 2022 (v17.5.5) Options:

    Options/SQL Server Tools/Transact-SQL Editor/Query Execution/General: Default SQLCMD mode

    Options/SQL Server Tools/Transact-SQL Editor/Query Execution/Advanced: SET NOEXEC