Solved

CLR Stored Procedures: how to set the schema/owner?

Posted on 2009-05-13
9
554 Views
Last Modified: 2012-05-06
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.
0
Comment
Question by:Sisupoika
  • 5
  • 4
9 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 24380857
I've never attempted, but have you tried the "create procedure SCHEMANAME.PROCEDURENAME" syntax?
0
 

Author Comment

by:Sisupoika
ID: 24380970
Thanks for replying, but I am afraid you have misunderstood the question :)
It's about CLR stored procedures, not normal ones.
I usually use schemas with normal SPs with no problems, but I don't know how to do the same with CLR SPs.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 24388454
I'm not confused.


create procedure SCHEMANAME.PROCEDURENAME

as

external name blah.blah.blah

GO

Open in new window

0
 

Author Comment

by:Sisupoika
ID: 24389692
I am sorry, perhaps I am the confused one and have misunderstood your suggestion :)
Using your method gives me the possibility to call the stored procedure with the schema+procedure_name that I want, but wouldn't it still show two items instead of one?
Many thanks for your help.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 24391568
If you have already created your CLR proc in a different schema, you would have to drop it and update all references to the one created in the desired schema.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 24391572
Using your method gives me the possibility to call the stored procedure with the schema+procedure_name that I want,


No, that is a CREATE procedure statement.
0
 

Author Comment

by:Sisupoika
ID: 24393565
Just to make sure I am following :)

So, I first deploy the CLR stored procedures from within Visual Studio, then I can drop the ones it creates with the dbo schema, and create new references with whichever schema name I want, by using the command you showed me. Is this what you are saying? :)

If yes, what shall I specify as external name?
Say the CLR stored procedure VS creates with the deployment has name 'GetSurveyQuestions', with schema 'dbo'. That is, dbo.GetSurveyQuestions.
Say I organize the database objects in 'modules' by using different schemas, and I want the 'GetSurveyQuestions' sp to appear as 'SurveyModule.GetSurveyQuestions' rather than 'dbo.GetSurveyQuestions'.
How shall I actually proceed?

What do I put as external name in

create procedure SCHEMANAME.PROCEDURENAME
as
external name blah.blah.blah
GO

?

Many thanks for all your help, the points are already yours but I haven't got it 100% :D
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 24396576
"So, I first deploy the CLR stored procedures from within Visual Studio, then I can drop the ones it creates with the dbo schema, and create new references with whichever schema name I want, by using the command you showed me. Is this what you are saying? :"

Yes.  Or just don't deploy from VS first.

The external name is the namespace path to the procedure in your code.  I'm sure there is an option somewhere in VS to specify the schema you want to deploy to.
0
 

Author Closing Comment

by:Sisupoika
ID: 31580898
Sorry for the delay. I am not deploying anymore from within Visual Studio in favour of scripts where I can use the method you suggested, with better control.
Many thanks for your help.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now