Stored procedures are basically a list of sql statement that needs to be executed. it works a function in our programming languages. Like you create a function and call it when ever you want.
So the stored procedures has the following advantages:
- Performance: stored procedures are complied the first time and then saved in the executable format so whenever you execute them, it gets executed quickly.
- It improved the response time as a group of instructions are executed in one call.
- Other thing is Sql server will execute instructions faster than the client side so you can use this feature to save time.
in order to create a stored procedure use the following command:
create procedure <Procedure name>
as
<statements>
to execute the procedure use:
exec/execute <procedure name>;
to delete a procedure:
drop procedure/proc <procedure name>;
Parameters in Stored Procedures: