Reputation: 227
We keep the changes of the sql server tables as script in TFS. When i get a change script from SMSS, there is some line at the bottom of the script. Which is;
select
Has_Perms_By_Name(N'dbo.MyTableName', 'Object', 'ALTER') as ALT_Per,
Has_Perms_By_Name(N'dbo.MyTableName', 'Object', 'VIEW DEFINITION') as View_def_Per,
Has_Perms_By_Name(N'dbo.MyTableName', 'Object', 'CONTROL') as Contr_Per
What is the purpose of this line? Does it matter if i ommit this line from my script files?
Upvotes: 3
Views: 1300
Reputation: 4645
The function Has_Perms_By_Name(...)
evaluates the permission of the current user on a table.
The syntax is:
HAS_PERMS_BY_NAME ( securable , securable_class , permission
[ , sub-securable ] [ , sub-securable_class ] )
whereas
securable: Is the name of the securable. If the securable is the server itself, this value should be set to NULL. securable is a scalar expression of type sysname. There is no default.
securable_class: Is the name of the class of securable against which the permission is tested. securable_class is a scalar expression of type nvarchar(60).
permission: A nonnull scalar expression of type sysname that represents the permission name to be checked. There is no default. The permission name ANY is a wildcard.
sub-securable: An optional scalar expression of type sysname that represents the name of the securable sub-entity against which the permission is tested. The default is NULL.
sub-securable_class: An optional scalar expression of type nvarchar(60) that represent the class of securable subentity against which the permission is tested. The default is NULL.
The return type of the function is an int and defines, if the current user has the specified permissions.
Also, take at look at this link
Upvotes: 1
Reputation: 21505
The query reports the current user's permissions against the target object using a built-in function HAS_PERMS_BY_NAME
.
It's not required for version control, so you could omit it.
Upvotes: 2