0

I have sql project in visual studio and I created pre-deployment script

/*
 Pre-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be executed before the build script.   
 Use SQLCMD syntax to include a file in the pre-deployment script.          
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the pre-deployment script.        
 Example:      :setvar TableName MyTable                            
               SELECT * FROM [$(TableName)]                 
--------------------------------------------------------------------------------------
*/

:setvar TableName MyTable                           
SELECT * FROM [$(TableName)]    

but Iam getting an error at :setvar line

Incorrect syntax near ':'.

what am I missing ?

0

1 Answer 1

2

Community wiki answer:

You need to switch to SQLCMD mode in Visual Studio via the menu SQL > Execution Settings.

You can also have all SQL files open in SQLCMD mode by default if you dig into Options > SQL Server Tools > Query Execution.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.