我在工作中获得了Visual Studio 2012的祝福。我得到的任务之一是进行开发数据库和系统测试数据库之间的架构。这一切都很好,但是当我生成脚本以移交给移民团队时,我会在标题上得到这个:
/*
Deployment script for MyGloriousDatabase
This code was generated by a tool.
Changes to this file may cause incorrect behavior and will be lost if
the code is regenerated.
*/
GO
:setvar DatabaseName "MyGloriousDatabase"
:setvar DefaultFilePrefix "MyGloriousDatabase"
:setvar DefaultDataPath "C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA"
:setvar DefaultLogPath "C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA"
GO
:on error exit
GO
/*
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"
GO
IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
BEGIN
PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
SET NOEXEC ON;
END
GO
USE [$(DatabaseName)];
...
现在,将其修剪成并将其制成.sql脚本并不困难,您可以简单地在SSM中运行。但是我已经看到,以前的Visual Studio版本具有"导出到Transact-SQL"选项。该选项在2012年隐藏吗?我能找到的最好的选择是评论SQLCMD行。
谢谢!
我也看不到可以执行此Visual Studio 2013 Premium的选项,但是可以通过QUERY-> sqlcmd模式菜单项来通过SQL命令模式来在SSM中运行生成的脚本在SSM中。
请参阅:SQL-Server-Setvar-Error