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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 return varchar value

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-28 : 18:07:51
Hello,
is it possible to return a value of varchar to a calling SP ?

I Tried using a simple SP, But not working


CREATE PROCEDURE dbo.Get (
@return varchar(max) OUTPUT )
AS
SELECT @return = 'test'
return @return



Msg 245, Level 16, State 1, Procedure G, Line 5
Conversion failed when converting the varchar value 'test' to data type int.


_____________________


Yes O !

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-09-28 : 19:11:28
Return only works with ints, but you can use an output parameter.

CREATE PROCEDURE dbo.Get (
@return varchar(max) OUTPUT )
AS
SELECT @return = 'test'
GO

DECLARE @OutputVar VARCHAR(MAX)
EXEC dbo.Get @OutputVar OUTPUT

SELECT @OutputVar


--
Gail Shaw
SQL Server MVP
Go to Top of Page

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-29 : 03:55:57
thank u

_____________________


Yes O !
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-29 : 06:07:32
This type of question, "how to return char data from sp" has now been asked 8 times last few days.
Are all attending same class?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-29 : 06:22:54
suggest you go through the below link to get an idea of how to return value through stored procs

http://www.sqlteam.com/article/stored-procedures-returning-data
Go to Top of Page

doco
Yak Posting Veteran

77 Posts

Posted - 2008-09-30 : 00:30:29
quote:
Originally posted by Peso

This type of question, "how to return char data from sp" has now been asked 8 times last few days.
Are all attending same class?



They were supposed to and didn't - so they missed the part about stored procedures...

Education is what you have after you've forgotten everything you learned in school
Go to Top of Page
   

- Advertisement -