I have a sql script say "abc.sql" which I am calling from a batch file using sqlcmd like
Calling batch script like
script.bat arg1 arg2
In batch
param1=%1 param2=%2
Then calling SQL script like
sqlcmd -S server -i abc.sql -v var1=%param1% var2=%param2%
In SQL script
DECLARE @node as sysname; DECLARE @serv as sysname; SET @node = $(var1); SET @serv = $(var2);
But this giving erro while I call the batch script "Invalid column name 'XXXXXXXX'"
where 'XXXXXXX' is the value of var1. What I am doing wrong. any idea.
Again, even though the scalar variable @node and @serv is declared and set ... I get an error saying Must declare the scalar variable "@node"