views:

531

answers:

1

Hi there, I am working on a Linq based CLR Stored Procedure for some complex filtering and manipulation, which would otherwise require a lot of messy and poorly performant T-SQL code, if implemented in a more "traditional" Stored Procedure.

This is working great, but I can't find how to set the schema of this Stored Procedure in phase of deployment, for a better organization and separation of the database objects in modules.

Any ideas?

Many thanks in advance.

+1  A: 

When you create the procedure referencing the assembly you can create this wrapper being owned by any schema you want. See This MSDN article on deploying CLR stored procedures for a walkthrough of how to do deploy a stored procedure. By changing the create procedure statement to something like:

CREATE SCHEMA foo

CREATE PROCEDURE foo.hello
AS
EXTERNAL NAME helloworld.HelloWorldProc.HelloWorld

You can now have a procedure owned by the foo schema.

ConcernedOfTunbridgeWells
Many thanks. I had found that article and I can see it as a workaround, but I was wondering whether there are any other alternative which would not require a wrapper or anyway a second object. Are you aware of any or is this the only actual possibility?Again, thanks for the prompt response :)
Vito Botta
The SQL wrapper is a necessary part. You have to do that anyway - it is an integral part of deploying CLR stored procedures.
ConcernedOfTunbridgeWells
Many thanks and sorry for the delay, have been busy with something else in the meantime. I am not deploying anymore directly from Visual Studio. Instead, I am deploying via scripts, so I can more easily specify the schema I want by using a wrapper, as you suggested.Many thanks again for your help.
Vito Botta