How Does one Save a Stored Procedure

In Microsoft SQL Server Management Studio Express you can right click on "Stored Procedures" under a database in the object explorer and the resulting Context Menu offers a selection called "New Stored Procedure".

If you select  "New Stored Procedure", a Stored Procedure Template Document is added for editing.  It has the suffix ".sql";  I can save this document to the file system after I edit it, but  I cannot figure out how to add it to the database as a Stored Procedure.

Can someone please tell me how to do this.

 

Thank you.

 



Answer this question

How Does one Save a Stored Procedure

  • IDO

    Click the "! Execute" button.

     

    Peter



  • G-wiz

    When you 'execute' stored procedure code, it is 'saved' to the current database. Using SSMS or SSMSE, if you do not see it listed under [Programmability]. [Stored Procedures], then you may have been unknowingly using a different active database. Check the [Database] drop down in the Toolbar to verify that you are in the correct database.

    I also recommend that you go to the [File] menu and save the stored procedure in its own file, in a location where you will be able to find it. (Preferabley, that would be in a source control tool.)



  • A1ien51

    Thank you very much!!! How did I miss that
  • clauden

    I cannot save a stored procedure also. It generates an sql file as you said, but does not add the procedure to the database. Microsoft said that there should be an Open button where the procedure will open in a text editor where you do your changes. The catch is there is no Open command when you right click on the procedure, as Microsoft has illuminated the steps for successful computing.



  • n1patrick

    Did not solve the problem for me. I created a stored procedure but, as you noted, could only save it to the project folder. I clicked !Execute but that did not save the procedure to any place my application can fin it--and it does not show up in the stored procedures folder. What is the magic solution

    Duncan



  • How Does one Save a Stored Procedure