pauldes
asked on
Using Select statement as parameter for SPROC
I have an sproc that has parameter A(varchar(30) and parameter B(binary(8).
parameter B is a record ID in my database
If I execute
rsp_getnewidwithretval 'Distribution',0x000000000 0002ED1
It works, BUT I'm trying to dynamically assign parameter B. I've tried many variations including:
exec rsp_getnewidwithretval 'Distribution',(Select Top 1 Distribution_ID from Distribution)
AND
Select Top 1 Distribution_ID from Distribution
exec productioned.dbo.rsp_getne widwithret val 'Distribution',Distributio n_Id
but end up getting:
Incorrect syntax near '('.
or
Implicit conversion from data type nvarchar to binary is not allowed. Use the CONVERT function to run this query.
HELP.....Thanks
parameter B is a record ID in my database
If I execute
rsp_getnewidwithretval 'Distribution',0x000000000
It works, BUT I'm trying to dynamically assign parameter B. I've tried many variations including:
exec rsp_getnewidwithretval 'Distribution',(Select Top 1 Distribution_ID from Distribution)
AND
Select Top 1 Distribution_ID from Distribution
exec productioned.dbo.rsp_getne
but end up getting:
Incorrect syntax near '('.
or
Implicit conversion from data type nvarchar to binary is not allowed. Use the CONVERT function to run this query.
HELP.....Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, leave my post, Angel is right
ASKER
Thanks
> exec productioned.dbo.rsp_getne
the sysntax for exec is
exec ('ur dynamic code')