tags:

views:

37

answers:

2

On SQL Server 2008, how can I place my stored procedures in "Stored Procedures" folder of my DB?

When I declare it this way:

CREATE PROCEDURE mySchema.myProc

It goes to:

MYSERVER\System Databases\Master\Programmability\Stored procedures folder.

How to tell server, to store it in:

MYSERVER\System Databases\MYDB\Programmability\Stored procedures folder.

EDIT:

If I declare it like that:

CREATE PROCEDURE [myDB].mySchema.myProc

It complains about:

'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.

If I use the 'USE' keyword, It complains:

a USE database statement is not allowed in a procedure, function or trigger.

Maybe the problem is that I'm using MS Management Studio, and connecting directly to the server, and not to any particular DB?

+5  A: 

It looks like you are creating the procedure in master database instead of your database. Add Use MYDB above the create script of the stored procedure and it will be created in your database.

Giorgi
+3  A: 

Try the following

USE MyDb 
GO 
CREATE PROCEDURE mySchema.myProc
Rob