Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,i have a stored procedure sp1,having structure like this
C#
create procedure sp1 
@id int,
@name varchar(5),
@rank int output

And i have one more stored procedure like this
C#
create procedure sp2 
@user varchar(50)

In this sp2 procedure i need to call sp1 like:
C#
exec sp2(select id,name,rank from tbltemp where name!=null)

But it is throwing error like
<br />
<br />
Procedure or function 'sp2' expects parameter '@rank', which was not supplied.


Thanks for any help in advance.
Posted
Updated 3-Dec-13 22:18pm
v2
Comments
Mahendran Murugesan 4-Dec-13 4:22am    
Hi,
1. You cannot pass the sql statement directly to SP2
2. You need to pass single row value to sp1 inside SP2 using select statement with row selector.

pass the value as shown in below format
Declare @id int
Declare @name varchar(5)
Declare @rank int
Select top 1 @id = id, @name = name from tbltemp where name != null -- top 1 include to select first user.
Exec sp1 @id , @name, @rank out
select @rank

Hope it helps
Maciej Los 4-Dec-13 17:55pm    
Please, post it as an answer and i'll promise you to upvote your answer ;)
njdcjk 4-Dec-13 4:58am    
Thanks a lot.U saved my day.+1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900