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.
Author |
Topic |
markus27183
Starting Member
4 Posts |
Posted - 2014-09-18 : 06:44:32
|
HiWhen I execute the SP that is created by:CREATE PROCEDURE [dbo].testSPAS BEGIN DECLARE @retval varchar(200); SET @retVal = 'ok.'; RETURN @retVal;END GOi.e. running EXEC testSPgives the error:Msg 245, Level 16, State 1, Procedure testSP, Line 7Conversion failed when converting the varchar value 'ok.' to data type int.But I want the return type to be a varchar(200);What am i doing wrong? |
|
markus27183
Starting Member
4 Posts |
Posted - 2014-09-18 : 06:49:50
|
actually the same error comes from this simplified example:CREATE PROCEDURE [dbo].testSPAS -- EXEC [testSP] BEGIN RETURN 'ok'END GO |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2014-09-18 : 07:03:10
|
Return value can not be anything other than integer.You either have to use OUTPUT parameter or SELECT statement to return varchar value to the caller.Harsh Athalyehttp://www.letsgeek.net/ |
|
|
markus27183
Starting Member
4 Posts |
Posted - 2014-09-18 : 07:49:26
|
The return type of an SP must be an integer (or nothing)To get it to give you back rows, you have to use a SELECT |
|
|
|
|
|