I am referencing a source column in my SQL Command task and receiving an error “Incorrect syntax near myvalue”. Below is the code I am using in my task.
DECLARE @MySQLVariable varchar(max)
Set @MySQLVariable = _MY_SOURCE_COLUMN
When referencing a source column or a global variable in a SQL Command Task, SmartConnect will replace the source column name or global variable name with the actual value. If that value is a string, we need to put single quotes around the source column or global variable so that when it is replaced, it will become the literal string.
As the code below illustrates, we use single quotes to represent the source column value.
DECLARE @MySQLVariable varchar(max)
Set @MySQLVariable = ‘_MY_SOURCE_COLUMN’
Similarly, we can do the same for global variables
DECLARE @MySQLVariable varchar(max)
Set @MySQLVariable = ‘GBL_MYGLOBALVARIABLE‘