I would like to know if in SQL is it possible to return a varchar value from a stored procedure, most of the examples I have seen the return value is an int
Example within a proc
declare @ErrorMessage varchar(255) if @TestFlag = 0 set @ErrorMessage = 'Test'
return @ErrorMessage
calling on asp.net
Updated:
Error:
Conversion failed when converting the varchar value ‘Development’ to data type int.
using (DataContextDataContext dc = conn.GetContext())
{
string serverName = ""
var result = dc.spGetServerName(ref serverName);
return result.ToString();
}
No, you can’t return anything but an int using the RETURN statement.
You’d need to use OUTPUT parameters instead. They are more flexible.
e.g.
Update:
For an example on how to retrieve the output param, see this article.