Translate

Wednesday, February 8, 2012

sql stored procedure output parameters



Stored Procedure with output parameter



CREATE PROCEDURE [dbo].[usp_OutPara]
@x int output,
@s varchar(max)
AS
BEGIN

set @x=1

select @s

END





Execute the stored proc and read the output variable




DECLARE @x INT
DECLARE @x2 INT

DECLARE @s VARCHAR(MAX)
set @s='hello world'

EXEC Usp_outpara
  @x=@x2 OUTPUT,
  @s=@s


SELECT @x2 --Displays 1

To read the output variables in asp.net check out 

No comments:

Post a Comment

Comments will appear once they have been approved by the moderator