SQL Server ':setvar' Error

SQL Server ':setvar' Error

回答1

The :setvar only works in SQL command mode, so you are possibly within normal SQL execution in the management studio and have not swapped to command mode.

This can be done through the user interface in SQL Server Management Studio by going to the "Query" menu, and selecting "SQLCMD mode."

 

評論:

This is also an issue when using Visual Studio's: Data > Schema Compare utility. If you run the resulting change script from within the utility you are fine, but if you decide to export/xcopy the change script after doing a comparison and then try to import/paste the resulting change script into SSMS then as above it will fail. Obviously this could also be an issue if you were including the db change script in a bundled deployment. So you need to turn on the SQL command mode before running the script either via the menu as above or ensure your custom install script does so before it runs.
– rism
May 20, 2012 at 1:39
 
 
 
回答2
Just enable sqlcmd mode in SQL Server Management Studio as described in following image.
 
 
 
 
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章