I want to find out all the source table name for the columns in a view in SQL server 2014.
I know this question is similar to this but my problem is my view uses tables from multiple databases.
Things that I have tried so far:
SELECT *
FROM INFORMATION_SCHEMA.VIEW_COLUMN_USAGE AS cu
JOIN INFORMATION_SCHEMA.COLUMNS AS c
ON c.TABLE_SCHEMA = cu.TABLE_SCHEMA
AND c.TABLE_CATALOG = cu.TABLE_CATALOG
AND c.TABLE_NAME = cu.TABLE_NAME
AND c.COLUMN_NAME = cu.COLUMN_NAME
WHERE cu.VIEW_NAME = '<your view name>'
AND cu.VIEW_SCHEMA = '<your view schema>'
This only gives column and table name from current database. I need something similar but from all the databases used in my view.
Feel free to ask questions if I am not clear.