fahad11


hi everyone...

Iam new with stored procedure in Sql 2005

so iam facing a problem which i need to get the result of query to store in an sql output parameter

here is my SP :

ALTER PROCEDURE [dbo].[CheckUser]

(

@Id nvarchar(50) ,

@Pass nvarchar(50) ,

@Exist int output ,

@Type char(1) output

)

AS

BEGIN

SET NOCOUNT ON;

-- Insert statements for procedure here

declare @tt int

declare @char char

select @tt=count(*) from Users where Id=@Id and Password=@Pass

select @char=users.Type from users where Id=@Id and password=@Pass

set @Type=@char

set @Exist=@tt

END

so i would to retrieve the results of the 2 queries & store them in @Exist & @Type..

how can i do that





Re: problem with Stored procedure

Madhu K Nair


Check this

ALTER PROCEDURE [dbo].[CheckUser]

(

@Id nvarchar(50) ,

@Pass nvarchar(50) ,

@Exist int output ,

@Type char(1) output

)

AS

BEGIN

SET NOCOUNT ON;

-- Insert statements for procedure here

select @Exist =count(*) from Users where Id=@Id and Password=@Pass

select @Type=users.Type from users where Id=@Id and password=@Pass

END

declare @tt int

declare @char char

Exec [CheckUser] 1,1,@tt output,@char Output

print @tt

print @char

basically when you have output parameter this is how you call a SP

Madhu







Re: problem with Stored procedure

fahad11

thanks alot...