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
 Old Forums
 CLOSED - General SQL Server
 assign a stored procedure value in a variable

Author  Topic 

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2006-09-08 : 05:25:13
Hi
How i assign a stored procedure value in a variable

Ranjeet Kumar Singh

nr
SQLTeam MVY

12543 Posts

Posted - 2006-09-08 : 08:17:54
create proc x
@a int
as
declare @s varchar(10)
select @s = convert(varchar(10),@a)
go

exec x 5

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2006-09-08 : 08:44:23
Hi
I want to assign stored procedure output records into a variable
for example
if my procedure is

create procedure Vechile
as
declare @a1 integer
select @a1=Vid from Vechiletrack

I want like as

declare @b1 integer
set @b1 =exec Vechile

(i want to assign exectuion value of stored procedure into variable)


Ranjeet Kumar Singh
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-08 : 08:48:41
I think you can make a parameter in/out, such as
CREAT PROCEDURE Vehicle
(
@Param VARCHAR(5) OUTPUT
)
...
SET @Param = 'Peso'
...
use with

DECLARE @p VARCHAR(5)
EXEC Vehicle @p OUT
Print @P


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -