3

I have been blessed with Visual Studio 2012 Premium at work. One of the tasks I've been given is to do a schema compare between development and system test databases. This is all well and good, but when I generate the script to hand over to the migration team, I get this at the header:


/*
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)];
...

Now, it is not difficult to trim this out and make it into an .sql script you can simply run in SSMS. But I have seen that previous versions of Visual Studio had an "Export to Transact-SQL" option. Is that option hidden in 2012? The best I can find is an option to comment out SQLCMD lines.

Thanks!

1 Answer 1

8

I do not see an option to do this Visual Studio 2013 Premium either, however the generated scripts can be run in SSMS by turning on SQL Command Mode via the Query->SQLCMD Mode menu item in SSMS.

See: sql-server-setvar-error

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.