T-SQL Stored Procedures
The Stored procedure in Transact SQL is used to save time to write the code, again and again. It does this by storing the procedure in database and get the required output by passing the parameters.
Below is the syntax of stored procedure creation.
Parameter Optional: When we create a procedure then one or more parameters are passed into the procedure. There are 3 types of parameters in stored procedure:
declaration_section in the procedure is where we declare local variables in the section.
In executable_section, the procedure where we enter the code for the procedure.
See the CUSTOMERS table which have the below records.
The following command is the example, which will fetch all the records from the CUSTOMERS table in the testdb database.
The command will produce the below output.