How to place a stored procedure in the right place?

In SQL Server 2008, how can I put my stored procedures in the stored procedures folder of my database?

When I declare it as follows:

CREATE PROCEDURE mySchema.myProc

He goes to:

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

How to tell the server to save it to:

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

EDIT:

If I declare it like this:

CREATE PROCEDURE [myDB].mySchema.myProc

He complains:

'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.

Perhaps the problem is that I use MS Management Studio and connect directly to the server, and not to any specific database?

+5
source share
2 answers

Try to execute

USE MyDb 
GO 
CREATE PROCEDURE mySchema.myProc
+13
source

, , . Use MYDB script .

+6

All Articles