I want to add a trigger to my table in an SSDT database defined in Visual Studio 2013. Triggers can be added through "Add New Trigger" in the visual table view. However, using SQLCMD variables seems to not be an option within the table definition because it's included in the build. So I created a postdeploy script that will add the trigger, which also produces errors. Adding the triggers as a standalone script runs fine but fails to actually add the trigger, so it looks like it just does nothing.
Variables are defined in project properties as $(VariableName)
They always produce useless errors no matter how they are used. I am using said variables in other places, but there seems to be something special when creating a trigger.
Using them like that directly like:
DECLARE @variable nvarchar(50) = $(VariableName)
Error: "SQL80001: Incorrect syntax near 'VariableName'. Expecting '(', or SELECT"
Putting them in a string like:
DECLARE @variable nvarchar(50) = '$(VariableName)'
Just sets the variable name to the variable without retrieving the configured value.
Enclosing it in square brackets like:
DECLARE @variable nvarchar(50) = [$(VariableName)]
Removes the error on compile and retrieves the value, but on deploy it produces the error: "Invalid column name 'value'"
What's the correct way/place to make triggers with SQLCMD configuration?
Aucun commentaire:
Enregistrer un commentaire