I have to grant permissions to a view. dbo.my_view, however, this view joins many tables, and other views and synonyms.
using the following script I can find all all the synonyms in my server:
Script to list synonym contents
SELECT
name as synonymName,
base_object_name as synonymDefinition,
COALESCE(PARSENAME(base_object_name,4),@@SERVERNAME) AS serverName,
COALESCE(PARSENAME(base_object_name,3),DB_NAME(DB_ID())) AS dbName,
COALESCE(PARSENAME(base_object_name,2),SCHEMA_NAME(SCHEMA_ID())) AS schemaName,
PARSENAME(base_object_name,1) AS objectName
FROM sys.synonyms
ORDER BY serverName,dbName,schemaName,objectName
If I have to grant select on dbo.myview how can I find out what select permissions I need to grant in any other databases that because of the synonyms also need to be granted?
how to grant permissions...but I actually wanted to find out all of these bloody synonyms inside that enormous view, so that I could grant permissions to all databases\database objects individually. I have given you +1 because it is a wonderful explanation that I will also need when dealing with certificates. thank you. – Marcello Miorelli Nov 28 '17 at 12:00