One, stored procedures
A stored procedure is a set of T-SQL statements that are compiled in a single execution plan
Stored procedures: Like functions are saved in the database (programmability)
Advantages of stored procedures:
1. Allow modular programming
2. Allow for faster execution if an operation requires a large number of T-SQL code or needs to be repeated, the stored procedure will be faster than the T-SQL batch code execution. It is parsed and optimized when the stored procedure is created, and you can use the in-memory version of the procedure after the first execution of the procedure.
3. Reduce network traffic
4. An operation that requires hundreds of lines of T-SQL code can be implemented by a separate statement that executes the procedure code without the need to send hundreds of lines of code in the network.
5. Use as a security mechanism
Write
SQL Server T-SQL stored procedure triggers