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.
 
 
 
 
 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2018-11-21 embed git commit hash to assembly
点击右上角即可分享
微信分享提示