我很幸运在工作中使用了 Visual Studio 2012 Premium。我被分配的任务之一是在开发和系统测试数据库之间进行模式比较。这一切都很好,但是当我生成脚本以移交给迁移团队时,我在标题中得到了这个:
/*
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 Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\"
:setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\"
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 脚本并不难,您可以简单地在 SSMS 中运行。但我看到以前版本的 Visual Studio 有一个“导出到 Transact-SQL”选项。该选项是否隐藏在 2012 年?我能找到的最好的方法是注释掉 SQLCMD 行。
谢谢!