How to save a Stored Procedure?
Steps:
- Write the stored procedure command in query window.
- Run the query
- Refresh the entire database in stead of the stored procedure folder.
- You shall see the stored procedure name. :)
You actually have to run the CREATE PROCEDURE
command so that the Stored Procedure builds.
Create Procedure - MSDN
Here's an example straight from the MSDN page:
USE AdventureWorks;
GO
-- If procedure exists already, drop it
IF OBJECT_ID ( 'HumanResources.uspGetAllEmployees', 'P' ) IS NOT NULL
DROP PROCEDURE HumanResources.uspGetAllEmployees;
GO
-- Create (or Re-create) the procedure
CREATE PROCEDURE HumanResources.uspGetAllEmployees
AS
SET NOCOUNT ON;
SELECT LastName, FirstName, JobTitle, Department
FROM HumanResources.vEmployeeDepartment;
GO
Remember that after you create the Stored Procedure, you will have to Right Click -> Refresh
the Stored Procedure folder for the new procedure to appear.
I would also suggest saving the *.sql file somewhere so you have the CREATE PROCEDURE
script somewhere in case you need to run again.
you have to actually run the create proc statement.