If you've ever written a VBA function or event procedure, you understand the concept of creating a block of code that achieves a specific result and may include flow-control statements and accept or return argument values. This concept describes SQL Server stored procedures, which are named, saved code routines that perform operations on server data. They're written in the Transact-SQL language (T-SQL for short). Here are the primary attributes of a stored procedure:
It's compiled at the time it's saved on the server so that it executes quickly.
Because it's a database object, security permissions/restrictions can be applied to it by using SQL Server's security model.
It can accept parameters and can return values—variables ...