SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how return string value from stored procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

yaman
Posting Yak Master

India
213 Posts

Posted - 04/03/2008 :  07:27:25  Show Profile  Reply with Quote
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

USA
7423 Posts

Posted - 04/03/2008 :  08:37:57  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
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 - 04/03/2008 :  09:28:14  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000