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
 General SQL Server Forums
 New to SQL Server Programming
 how return string value from stored procedure

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2008-04-03 : 07:27:25
This procedure gives a error : " Msg 245, Level 16, State 1, Procedure YAMAN, Line 16
Conversion failed when converting the nvarchar value 'user' to data type int. "
How can i return string value

ALTER procedure [dbo].[YAMAN]
(@username varchar(20),@active varchar(20))
as
begin
if exists (select username from aspnet_Users where username=@username)
begin
if @active=(select active from aspnet_Users where username=@username)
return 'already exist'
else
begin
update aspnet_Users set active=@active where username=@username
return 'update'
end
end
else
return 'user does not exist'
end

Yaman

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-04-03 : 08:37:57
Either return a single row, single column result set, using SELECT, or just use an output parameter.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-04-03 : 09:28:14
RETURN must be supplied an int value

In any case you shouldn't use return to try and return anything

SQL Server has the ability in certain cases to override anything you RETURN

ALTER procedure [dbo].[YAMAN]
@username varchar(20),@active varchar(20), @rc varchar(50) OUTPUT

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -