Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 adding additional parameter to exec sp_executesql

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-12 : 12:11:56
I want to add an additional parameter to this command:
exec sp_executesql N'exec pos_activation_diary_hrm @posid', N'@posid varchar(20)', @posid = @pos_id

The parameter is @payment_method, varchar(3).

How would I do so?

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-06-12 : 14:01:14
You will have to retrieve the current script for your pos_activation_diary_hrm procedure and alter it to accept the new parameter.

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-12 : 14:07:17
I understand how to do that. I am asking how I add the parameter to the exec sp_executesql statement I posted. I could not find an example with more than one parameter.
Go to Top of Page

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-06-12 : 14:59:10
You can't alter the built-in sp_executesql proc. I think what you want is to alter pos_activation_diary_hrm proc instead to accept your new parameter.

Some days you're the dog, and some days you're the fire hydrant.
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-12 : 15:29:39
I don't think you are understanding my question.

I want to go from:
exec sp_executesql N'exec pos_activation_diary_hrm @posid', N'@posid varchar(20)', @posid = @pos_id
to:
exec sp_executesql N'exec pos_activation_diary_hrm @posid, @payment_method', N'@posid varchar(20),@payment_method vahchar(3)', @posid = @pos_id, @payment_method = @payment_method

Something like this. What is the proper syntax for the second parameter?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-06-12 : 15:42:15
That looks correct to me. Are you getting an error or something?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-14 : 02:11:44
quote:
Originally posted by chedderslam

I don't think you are understanding my question.

I want to go from:
exec sp_executesql N'exec pos_activation_diary_hrm @posid', N'@posid varchar(20)', @posid = @pos_id
to:
exec sp_executesql N'exec pos_activation_diary_hrm @posid, @payment_method', N'@posid varchar(20),@payment_method vahchar(3)', @posid = @pos_id, @payment_method = @payment_method

Something like this. What is the proper syntax for the second parameter?


the syntax is correct. are you sure you've created stored procedure pos_activation_diary_hrm with the additional parameter @payment_method? if yes, then whats the problem you're facing
Go to Top of Page
   

- Advertisement -