What is stored procedure in SQL?

Solution

Stored procedures are precompiled set of SQL statements that are used to perform any task or operation and stored in SQL Database. Stored procedure accepts parameters like a function.

Stored procedures are very useful to improve the performance as the instructions written in stored procedure are compiled previously and execution plan for stored procedure is saved.

There are two types of Stored procedures

• System defined stored procedure - Inbuilt stored procedure e.g. sp_helptext, sp_who
• User defined stored procedure - defined by user