March 28, 2008 at 11:26 am
Hello, it seems like I'm doing this right and most of the examples on the net I've found have it this way too, so I'm not sure what I'm donig wrong.
Ok, I have a execute SQL task in my SSIS package which should fire a stored procedure which has 2 parameters (@StartDate and @EndDate). The stored procedure runs fine using a exec statement: exec [dbo].[zKMHP_Proprietary] '10/1/2007', '10/31/2007'
If I take the above statement and put it in a Execute SQL task and hit parse, it parses successfully. Now if I replace my values with parameters this statement (exec [dbo].[zKMHP_Proprietary] ?, ?) I get the error: "The query failed to parse. Syntax error, permission violation, or other nonspecific error"
I do have my parameter mapping with these two as well in the execute sQL task, but at the very least it should parse correctly since according to everywhere I've looked on the net this is the way to feed parameters into a stored procedure from SSIS execute SQL task. What am I doing wrong?
Thanks,
Strick
March 28, 2008 at 12:41 pm
The parse button does not work with question mark (?) parameterized queries. Does the task execute successfully?
March 28, 2008 at 3:05 pm
Yep you were right the task executes successfully. Thanks. But now I have a new issue stemming from this
The execute SQL task which runs the statement exec [dbo].[zKMHP_Proprietary] ?, ?) will run just fine, but the results of this stored procedure need to be inserted into another table. When I modify it to be:
INSERT INTO insert into zKMHP_Staging
exec [dbo].[zKMHP_Proprietary] ?, ?)
the task fails. I know the above statement is correct because if I take it and copy it to SQL Mgmt Studio, then change it to
INSERT INTO insert into zKMHP_Staging
exec [dbo].[zKMHP_Proprietary] '10/1/2007', '12/31/2007')
it runs just fine. Ideally, I'd rather use a data flow task to insert the results of a stored procedure into a table, but just haven't figured out how to do this since there are no outputs at design time. So I've tried using the Execute SQL task instead. But anyway, I'm not sure why it won't run when all I do is add the insert into to the task. Can you see anything else wrong?
Thanks,
Strick
March 31, 2008 at 6:17 am
Step 1 of dealing with digging yourself into a hole is to stop digging.
Here is what I think your situation is.
You have a procedure with some relatively complicated logic in it. The procedure uses a temp table and returns data from the temp table as the output data set.
The first thing to ask is if the business logic needs to be in a procedure. Can you do the logic in SSIS as efficiently or better? If so, write the logic pf the procedure in SSIS.
If you need to use a procedure for some reason, having a temp table can be a problem for SSIS because it cannot get column information at design time. To get around this, you can use a global temp table while designing and keep the table in a session that you do not close. You can even just create a stub version of your procedure that does nothing but select the column set:
CREATE PROC MyProc
AS
SELECT 'A' AS Col1, 'B' AS Col2...
This will allow you to have SSIS build the input and output columns (be very careful of data types).
You can do what you are suggesting - just run an insert from a procedure, but I would avoid it especially in the way you are doing it. If you must do this, include the insert as part of the procedure (even if you need to wrap this procedure with another one).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply