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?