Showing posts with label thatvalue. Show all posts
Showing posts with label thatvalue. Show all posts

Sunday, March 11, 2012

CLR Return Types

I would like my C# dll to return a float (value) so that I can use that
value within the SQL Server stored procedure. There seems to be a limitation
on the return types from CLR (CLR methods return either SqlInt32,
System.Int32, void.)
I would appreciate if anyone can suggest a workaround (if there is one).
Thanks.In SQL Server, procedures return either set a return code (which is INT ==
SqlInt32) or they don't (CLR return type is void). To return a value from a
stored procedure use a parameter of type OUTPUT in SQL Server (which
actually acts like ref in .NET) or use a user-defined function instead.
User-defined functions can return float (REAL in SQL Server) or double
(FLOAT in SQL Server) or other data types.
Cheers,
Bob Beauchemin
http://www.SQLskills.com/blogs/bobb
"KMP" <KMP@.discussions.microsoft.com> wrote in message
news:5CBF5704-0FF7-4C58-A81D-C8837416BA34@.microsoft.com...
> I would like my C# dll to return a float (value) so that I can use that
> value within the SQL Server stored procedure. There seems to be a
> limitation
> on the return types from CLR (CLR methods return either SqlInt32,
> System.Int32, void.)
> I would appreciate if anyone can suggest a workaround (if there is one).
> Thanks.|||I guess I don't quite understand what you are saying. Could you please be
more clear? I am not sure if my question is confusing, but I want to return
a
float value from a dll.
Thanks.
"Bob Beauchemin" wrote:

> In SQL Server, procedures return either set a return code (which is INT ==
> SqlInt32) or they don't (CLR return type is void). To return a value from
a
> stored procedure use a parameter of type OUTPUT in SQL Server (which
> actually acts like ref in .NET) or use a user-defined function instead.
> User-defined functions can return float (REAL in SQL Server) or double
> (FLOAT in SQL Server) or other data types.
> Cheers,
> Bob Beauchemin
> http://www.SQLskills.com/blogs/bobb
>
> "KMP" <KMP@.discussions.microsoft.com> wrote in message
> news:5CBF5704-0FF7-4C58-A81D-C8837416BA34@.microsoft.com...
>
>|||"KMP" <KMP@.discussions.microsoft.com> wrote in message
news:ACC4559E-3DB8-4E5A-BC3C-F6A4AA1E2477@.microsoft.com...
> I guess I don't quite understand what you are saying. Could you please be
> more clear? I am not sure if my question is confusing, but I want to
> return a
> float value from a dll.
You need to create a user-defined function rather than a stored
procedure.
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--