Can you call a SQL Stored Procedure that returns a record set and have those values loaded into vari
- by codingguy3000
Hello fellow stackers
Please consider the following SQL Server table and stored procedure.
create table customers(cusnum int, cusname varchar(50))
insert into customers(cusnum, cusname) values(1, 'Ken')
insert into customers(cusnum, cusname) values (2, 'Violet') --The Wife
create procedure getcus
@cusnum int
as
Begin
select cusname
from customers (nolock)
where cusnum = @cusnum
End
You know how you can write T-SQL code like this:
declare @cusname varchar(50)
select @cusname = cusname
from customers
where cusnum = 1
Can I do this with my stored procedure?
for example the code would look like this:
declare @cusnum int
declare @cusname varchar(50)
set @cusnum = 1
exec @cusname = cusname pbogetcus @cusnum
Thanks in advance.