tailieunhanh - Microsoft SQL Server 2008 R2 Unleashed- P95

Microsoft SQL Server 2008 R2 Unleashed- P95:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 884 CHAPTER 28 Creating and Managing Stored Procedures SELF This option is equivalent to EXECUTE AS user_name where the specified user is the person creating or modifying the stored procedure. OWNER This option specifies that the statements inside the stored procedure execute in the context of the current owner of the stored procedure. If the procedure does not have a specified owner the owner of the schema in which the procedure was created is used. OWNER must map to a single user account and cannot be a role or group. user_name This option specifies that the statements inside the stored procedure execute in the context of the user_name specified. Permissions for any objects within the stored procedure are verified against this user. The user specified must exist in the current database and cannot be a group role certificate key or built-in account. To determine the execution context of a stored procedure you can query the execute_as_principal_id column in either the or catalog view. Specifying an execution context for a stored procedure can be very useful when you want to define custom permission sets. For example some actions such as TRUNCATE TABLE cannot be explicitly granted to other users. However if you use the EXECUTE AS clause to set the execution context of a stored procedure to a user who does have truncate table permissions for example a user who has permissions to alter the table you can then incorporate the TRUNCATE TABLE statement within the procedure. Any user to whom you then grant EXECUTE permission on the stored procedure is able to run it to execute the TRUNCATE TABLE command contained in it. TIP When using the EXECUTE AS clause to customize the permission set for a stored procedure it is good security policy to specify a login or user that has the least privileges required to perform the operations defined in the stored procedure. Do not specify an account such as a database owner account unless those .

TỪ KHÓA LIÊN QUAN