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 2008 Forums
 Other SQL Server 2008 Topics
 CLR Stored procedure return type

Author  Topic 

shamin_a
Starting Member

2 Posts

Posted - 2011-12-26 : 00:44:58
Hi,

Thanks in advance for helping me. I just started working on CLR Stored procedure. I wanted the procedure to return me a string. After changing the return type to string Iam not able to deploy the stored procedure. Below is the error that I get. Any help will be highly appreciated.

CREATE PROCEDURE failed because a CLR Procedure may only be defined on CLR methods that return either SqlInt32, System.Int32, System.Nullable<System.Int32>, void.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-26 : 05:54:29
you were trying to alter CLR procedure within sql server?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-12-26 : 10:29:30
The error message describes what the issue is: CLR stored procs allow only void or integer return types. If you want to return a string to the calling program, you can do it using an output parameter. For example:
public static void YourCLRProc(out SqlString theString)

or
Public Shared Sub YourCLRProc( <Out()> ByRef theString As SqlString)
When you install the stored proc in T-SQL, use the OUTPUT qualifier as in
create proc dbo.YourTSQLProc(@yourstring nvarchar(255) OUTPUT)
AS EXTERNAL NAME ....
Go to Top of Page

shamin_a
Starting Member

2 Posts

Posted - 2011-12-26 : 11:17:54
@Sunita. Thank you very much. I will try the output parameter.
@visakh. No I was not altering the procedure from SQL Server. Just changing the return value type.

Thanks
Go to Top of Page
   

- Advertisement -