"What is a stored procedure" is already answered in other posts here. What I will post is one less known way of using stored procedure. It is `grouping stored procedures` or `numbering stored procedures`.
**Syntax Reference**
[![enter image description here][1]][1]
`; number` as per [this](
[To see links please register here]
)
>An optional integer that is used to group procedures of the same name. These grouped procedures can be dropped together by using one DROP PROCEDURE statement
**Example**
CREATE Procedure FirstTest
(
@InputA INT
)
AS
BEGIN
SELECT 'A' + CONVERT(VARCHAR(10),@InputA)
END
GO
CREATE Procedure FirstTest;2
(
@InputA INT,
@InputB INT
)
AS
BEGIN
SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO
**Use**
exec FirstTest 10
exec FirstTest;2 20,30
**Result**
[![enter image description here][2]][2]
**Another Attempt**
CREATE Procedure SecondTest;2
(
@InputA INT,
@InputB INT
)
AS
BEGIN
SELECT 'A' + CONVERT(VARCHAR(10),@InputA)+ CONVERT(VARCHAR(10),@InputB)
END
GO
**Result**
> Msg 2730, Level 11, State 1, Procedure SecondTest, Line 1 [Batch Start Line 3]
Cannot create procedure 'SecondTest' with a group number of 2 because a procedure with the same name and a group number of 1 does not currently exist in the database.
Must execute CREATE PROCEDURE 'SecondTest';1 first.
**References**:
1. [CREATE PROCEDURE with the syntax for number](
[To see links please register here]
)
2. [Numbered Stored Procedures in SQL Server - techie-friendly.blogspot.com](
[To see links please register here]
)
3. [Grouping Stored Procedures - sqlmag](
[To see links please register here]
)
**CAUTION**
1. After you group the procedures, you can't drop them individually.
2. This feature may be removed in a future version of Microsoft SQL Server.
[1]:
[2]: