Ive got a Database project running in JetBrains Rider.
The project publishes a DACPAC to create or update a target database.
Now I have a set of reference data scripts which run (in Create mode) and these are reference through
the Script.PostDeployment which looks like this:
Now i want to be able to pass a SQLCMD variable called 'Deploy' so that each script will only be executed depending on
the variable. So for example LoadUser would run like this
If $(DeployType) = 'Create'
INSERT [dbo].[User] ([UserID], [UserName]) VALUES (NEWID(), N'Swagger')
And therefore I would run sqlpackage as follows:
SqlPackage /Action:Publish /p:CreateNewDatabase=False /p:DropObjectsNotInSource=True /SourceFile:"C:\Users\user1\source\repos\metrology\TinytagExplorerMe
trology\Logger_Groups.Build\bin\Debug\netstandard2.0\Logger_Groups.Build.dacpac" /TargetDatabaseName:Logger_Groups_CI /TargetServerName:"localhost\SQLEXPRESS" /v:DeployType="Create"
However i cant get the project to compile as i get the following error
Incorrect syntax near If.
How can i set a SQLCMD variable in my scripts that can be called from SqlPackage?