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
 Return value of Sp into .net variable

Author  Topic 

pradeepmanne
Starting Member

31 Posts

Posted - 2011-11-24 : 10:12:01
hi all,
my storeprocedure will convert datatype into binary
i want the return value which is in binary form to be used
in my front end application
any solution

ALTER proc [dbo].[ConvertCharToBinary](@Value varchar(8000))
as
Begin
declare @return binary
select @return=(cast(CAST(@Value as char(8000)) as binary(8000)))
return(@return)
End

thanks inadvance

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-11-24 : 10:46:21
Stored procedures return datatype INT. If you want to get back binary, use an output parameter rather than the return value - for example:

create proc [dbo].[ConvertCharToBinary](@Value varchar(8000), @returnValue BINARY(8000) OUTPUT)
as
Begin
SET @returnValue = CAST(@Value AS BINARY(8000));
End

In your .net code, you should define the @returnValue parameter with ParameterDirection = Output or ParameterDirection = InputOutput, of type SqlDbType.Binary or SqlDbType.VarBinary.


Unless you want the binary
Go to Top of Page
   

- Advertisement -