开发者

Truncate table permissions

开发者 https://www.devze.com 2023-03-07 06:38 出处:网络
What are min permission we need to truncate table ? Apart from DDLAdmin. And what is best pratice to give permission to the user to tr开发者_C百科uncate the user on SQL 2008 R2Truncate table documenta

What are min permission we need to truncate table ? Apart from DDLAdmin. And what is best pratice to give permission to the user to tr开发者_C百科uncate the user on SQL 2008 R2


Truncate table documentation at books online here

Permissions

The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable. However, you can incorporate the TRUNCATE TABLE statement within a module, such as a stored procedure, and grant appropriate permissions to the module using the EXECUTE AS clause. For more information, see Using EXECUTE AS to Create Custom Permission Sets.


MSDN:

The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable.


If you don't want to grant rights (which are excessive, really, and described in other answers) you can escalate permissions within a stored procedure...

CREATE PROC DoTruncate
WITH EXECUTE AS OWNER
AS
TRUNCATE TABLE Mytable
GO

And permission this instead with "normal" rights

0

精彩评论

暂无评论...
验证码 换一张
取 消