4

My question is regarding to SQL schema compare.

Database Schema Compare

When i generate script using SQL schema compare, script is generating in below format.

/*
Deployment script for Student

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
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;


GO
:setvar DatabaseName "Student"
:setvar DefaultFilePrefix "Student"
:setvar DefaultDataPath "F:\Data\"
:setvar DefaultLogPath "H:\Logs\"

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)];

GO
PRINT N'Altering [dbo].[usp_InsertStudentData]...';
GO
.....

If i run below query in SQL Cmd mode then it is suppose to run.

But i dont want to run this query in SQL Cmd mode as our dba not approve this Now my question is...

I need to execute script which not include SQL Command mode code ":setvar DatabaseName"

Let me know if you need more help in my question.

Dan Guzman
  • 43,250
  • 3
  • 46
  • 71
yogesh
  • 45
  • 1
  • 8
  • SQLCMD scripts must run in SQLCMD mode. Why doesn't your DBA want to run the script in SQLCMD mode? – Dan Guzman Aug 11 '18 at 01:46
  • 1
    I have the same "problem"... I my case, my "DBA" is a client, so he is always right when he tells me that my script should not be using sql mode. Life is weird that way sometimes. – Remi Beaulieu Oct 30 '18 at 19:57

0 Answers0