Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I am trying to create some script variables in T-SQL as follows:

    /*

    Deployment script for MesProduction_Preloaded_KLM_MesSap

    */

   GO

    SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

  SET NUMERIC_ROUNDABORT OFF;

 GO :setvar DatabaseName "MesProduction_Preloaded_KLM_MesSap"

However, when I run this, I get an error stating 'Incorrect syntax near ':'. What am I doing wrong?

1 Answer

0 votes
by (40.7k points)

The: setvar will only work in SQL command mode, Hence you are possibly within the normal SQL execution in the management studio and have not swapped to command mode.

It can also be done through the user interface in SQL Server Management Studio by using the "Query" menu, and selecting "SQLCMD mode."

Related questions

0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)

Browse Categories

...