Reputation: 1055
What are the minimum permission(s) and to what object(s) do I need to give to a SQL server database role to get OBJECT_NAME
and OBJECT_SCHEMA_NAME
to return a value rather than a NULL
?
If there's something weird then I could just use the sys.objects
and sys.schemas
but I assumed that using OBJECT_NAME
and OBJECT_SCHEMA_NAME
would be the better approach for single value @@PROCID
access.
Upvotes: 2
Views: 773
Reputation: 3351
According to the MSDN pages for both OBJECT_NAME
and OBJECT_SCHEMA_NAME
:
Requires ANY permission on the object. To specify a database ID, CONNECT permission to the database is also required, or the guest account must be enabled.
So the answer is you need any permission on the object which you are passing to the function. Make sure you are definitely passing a valid object_id
(which is of type INT
and should correspond to an object_id
value for an object in the current or specified database) when you call your function.
Upvotes: 1