I am having problems creating an "Execute SQL Task" which calls a stored procedure.
I have tested the procedure successfully using parameters that I have hardcoded on the command line (i.e., EXEC procedure_name 1, 2). This works fine, but I'm having problems using variables(i.e., EXEC procedure_name @VAR1, @VAR2). I'm using a ConnectionType of OLE DB.
When I parse the Query I get an error message that says "The query failed to parse. Must declare the variable '@VAR'".
However, I have this variable declared and assigned a value. I have played around the Parameter Mapping pane but I'm not getting anywhere.
Can anyone shed some light on this particular problem and how I go about fixing this
thanks
John

Problem with Execute SQL Task
seattleboatguy
I had sp_GetDetails in my db that took one input (varchar type). I created a variable called "inputVal" and assigned a value to it. In my "Execute SQL task", I had "Execute sp_GetDetails @inputValParam" as my SQLStatement. I also created a mapping between inputVal and inputValParam using "Parameter Mapping" in my task. This task works if the connection type is ADO.Net. If I change that to OLE DB, it does not work.
TorB
John,
Place 'EXEC procedure_name , ' as the SQL Statement. Then, under Parameter Mapping, add a variable select User::Var1 (or whatever the name of Var1 is) as the variable name and enter '0' (zero) as the Parameter Name. Add another variable, select User::Var2 as the variable name and enter '1' as the Parameter Name. That should do it.
Also, I've never been able to parse a query with parameters in it.
Eric
SJVCT
bvautier
Kaarthik,
Kirk has a useful post which may help you here: http://sqljunkies.com/WebLog/knight_reign/archive/2005/10/05/17016.aspx
-Jamie
Zeljka
figu
Lale D
Simply use "EXEC procedure_name , , 1, NULL, 'Yes', , ". The question marks serve as placeholders for the parameters which you are going to map on the 'Parameter Mapping' page. The parameter list is a 0-based array. So your parameter names will be 0, 1, 2, 3, ..., n respectively, and they're placed into the SQL in the order they're named, so the first ' ' corresponds to parameter 0, the second ' ' corresponds to parameter 1, etc.
So, if I have User::var1 with a value of 'A' mapped to 0, User::var2 = 'B' -> 1, User::var3 = 'Jim' -> 2, User::var4 = 'Bob' -> 3 the SQL sent via the SQL task would be "EXEC procedure_name 'A', 'B', 1, NULL, 'Yes', 'Jim', 'Bob'".
Hope that doesn't confuse things more.
Eric