What Is a Stored Procedure In SQL Server?
Stored Procedure : A stored procedure in SQL Server is a precompiled collection of SQL statements that get cached and stored in the database in order to reused over and over again whenever required.
Advantage of using Stored Procedure
Following are the advantage of using stored procedure in SQL server.
- A stored procedure (SP) provides the reusability of SQL code as we can simply call the stored procedure Instead of writing the same SQL statements over and over again.
- It allows reducing the network traffic by executing the SQL statements at the server-side rather than sending hundreds lines of SQL queries over the network.
- A stored procedure can be used as a security mechanism by granting a user to execute only the stored procedure instead of allowing permission on the table.
- It allows faster execution of SQL statements in order to enhance the performance.