Click here to Skip to main content
15,888,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to check a stored proc by passing a value to it.

SQL
ALTER procedure [dbo].[Test] 
(@name varchar(50),@sal int
)
as
begin

select Sal from Salary where Name=@name
end


I have to pass a name to it and get salary here it self how can i do this??
Posted

it seems like you wat to get sal as output
SQL
ALTER procedure [dbo].[Test]
(@name varchar(50),@sal int out
)
as
begin
select @Sal = Sal from Salary where Name=@name
end


execute sp in sql
SQL
exec Test 'Name to pass', 0

Happy Coding!
:)
 
Share this answer
 
Include OUTPUT in your parameters if it's output. Check here[^] for details.
 
Share this answer
 
SQL
ALTER procedure [dbo].[Test]
(@name varchar(50)
)
as
begin

select Sal from Salary where Name=@name
end

exec [dbo].[Test] 'Your Name'
 
Share this answer
 
oops i forgot exec :( i got it now :)
 
Share this answer
 

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