|
Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - EXECUTE - Executing Stored Procedures
By: FYIcenter.com
(Continued from previous topic...)
How To Execute a Stored Procedure?
If you want execute a stored procedure created previously,
you can use the EXECUTE statement in the following formats:
EXEC procedure_name;
EXECUTE procedure_name;
The key word EXEC is actually optional. So you can execute
a stored procedure by just entering the procedure name as the statement.
See examples in the following tutorial exercise:
USE FyiCenterData;
GO
-- create a quick procedure
CREATE PROCEDURE date AS
PRINT CONVERT(VARCHAR(20),GETDATE(),107);
GO
-- execute with EXEC
EXEC date;
GO
May 19, 2007
-- execute with EXEC
date;
GO
May 19, 2007
-- using a reserved keyword as procedure name
CREATE PROCEDURE datetime AS PRINT GETDATE();
GO
datetime;
GO
May 19, 2007 11:35PM
Looks like SQL Server allows you to reserved keywords as stored procedure names.
(Continued on next topic...)
- What Are Stored Procedures?
- How To Create a Simple Stored Procedure?
- How To Execute a Stored Procedure?
- How To List All Stored Procedures in the Current Database?
- How To Drop an Existing Stored Procedure?
- How To Create a Stored Procedure with a Statement Block?
- How To End a Stored Procedure Properly?
- How To Generate CREATE PROCEDURE Script on an Existing Stored Procedure?
- How To Get the Definition of a Stored Procedure Back?
- How To Modify an Existing Stored Procedure?
- How To Create Stored Procedures with Parameters?
- How To Provide Values to Stored Procedure Parameters?
- What Are the Advantages of Passing Name-Value Pairs as Parameters?
- Can You Pass Expressions to Stored Procedure Parameters?
- How To Provide Default Values to Stored Procedure Parameters?
- How To Define Output Parameters in Stored Procedures?
- How To Receive Output Values from Stored Procedures?
- How To Create a Local Temporary Stored Procedure?
- Can Another User Execute Your Local Temporary Stored Procedures?
|