August 29, 2017 at 5:09 am
Hi All,
Is there any tool/tsql-query to pull all the tables involved in a sql query. Assuming it is a complex query which involves multi-table joins in that case how can find out the tables. Currently, I manually search for "FROM" clause and get table names one by one.
Below is an example of a complex query:
SELECT
"T1"."C1" AS "Institution_Number"
,"T1"."C2" AS "Portfolio"
,"T1"."C3" AS "Account_Number"
,"T1"."C4" AS "Account_Type"
,SUM( "T1"."C11" ) AS "Account_Balance"
,SUM( "T1"."C12" ) AS "CMTD_Average_Balance"
,SUM( "T1"."C13" ) AS "CYTD_Average_Balance"
,"T1"."C5" AS "Date_Closed"
,"T1"."C6" AS "Date_Opened"
,"T1"."C7" AS "Closed_Account_Flag"
,"T1"."C8" AS "Class_Code"
,"T1"."C9" AS "Product_Number"
,ISNULL("T1"."C10",CIS_Codes.Date_Last_Updated) AS "Date_Last_Updated"
,SUM(CASE
WHEN "T1"."C4" = 1
THEN "T1"."C14"
WHEN "T1"."C4" = 2
THEN "T1"."C15"
WHEN "T1"."C4" = 3
THEN "T1"."C16"
WHEN "T1"."C4" = 4
THEN "T1"."C17"
ELSE 0
END ) AS "Interest_Rate"
,"T1"."C0" AS "Name_ID"
,"T0"."C1" AS "Total_Deposit_Balance"
,"T0"."C2" AS "Total_Loan_Balance"
FROM
(
SELECT
"CIF_NAME"."NAME_ID" AS "C0"
,SUM(CASE
WHEN "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" BETWEEN 1 AND 3
THEN "CROSS_APP"."ACCOUNT_BALANCE"
ELSE 0
END ) AS "C1"
,SUM(CASE
WHEN "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = 4
THEN "CROSS_APP"."ACCOUNT_BALANCE"
ELSE 0
END ) AS "C2"
FROM ((((((("CIS_ATTACHED_ACCTS" "CIS_ATTACHED_ACCTS" WITH (NOLOCK)
INNER JOIN (
SELECT
"T1"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"T1"."NAME_ID" AS "NAME_ID"
,"CROSS_APPLICATION_NAME_TO_PORT"."PORTFOLIO" AS "PORTFOLIO"
,"T1"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
FROM (
SELECT
"T1"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"T1"."NAME_ID" AS "NAME_ID"
,"T1"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
,"T1"."PORT_SEQUENCE_NUMBER" AS "PORT_SEQUENCE_NUMBER"
,MIN("T1"."DATE_CREATED") AS "DATE_CREATED"
FROM "NAME_TO_ALL_ACCT" "T1" WITH (NOLOCK)
GROUP BY "T1"."INSTITUTION_NUMBER"
,"T1"."NAME_ID"
,"T1"."ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE"
,"T1"."PORT_SEQUENCE_NUMBER"
) "T1", "NAME_TO_PORT" "CROSS_APPLICATION_NAME_TO_PORT"
WHERE "T1"."INSTITUTION_NUMBER" = "CROSS_APPLICATION_NAME_TO_PORT"."INSTITUTION_NUMBER"
AND "T1"."NAME_ID" = "CROSS_APPLICATION_NAME_TO_PORT"."NAME_ID"
AND "CROSS_APPLICATION_NAME_TO_PORT"."RELATIONSHIP_CODE" IN (90, 91)
) "T13"
ON "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "T13"."ACCOUNT_NUMBER"
AND "CIS_ATTACHED_ACCTS"."PORTFOLIO" = "T13"."PORTFOLIO"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "T13"."APPLICATION_TYPE_CODE"
AND "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "T13"."INSTITUTION_NUMBER"
) LEFT OUTER JOIN (
"COD_ACCT" "COD_ACCT" WITH (NOLOCK)
INNER JOIN "COD_INTEREST" "COD_INTEREST" WITH (NOLOCK)
ON "COD_ACCT"."INSTITUTION_NUMBER" = "COD_INTEREST"."INSTITUTION_NUMBER"
AND "COD_ACCT"."COD_ACCOUNT" = "COD_INTEREST"."COD_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "COD_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "COD_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "COD_ACCT"."COD_ACCOUNT"
) LEFT OUTER JOIN (
"DDA_ACCT" "DDA_ACCT" WITH (NOLOCK)
INNER JOIN "DDA_INTEREST" "DDA_INTEREST" WITH (NOLOCK)
ON "DDA_ACCT"."INSTITUTION_NUMBER" = "DDA_INTEREST"."INSTITUTION_NUMBER"
AND "DDA_ACCT"."DDA_ACCOUNT" = "DDA_INTEREST"."DDA_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "DDA_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "DDA_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "DDA_ACCT"."DDA_ACCOUNT"
) LEFT OUTER JOIN (
"NOTE_ACCT" "NOTE_ACCT" WITH (NOLOCK)
INNER JOIN "NOTE_RATE" "NOTE_RATE" WITH (NOLOCK)
ON "NOTE_ACCT"."INSTITUTION_NUMBER" = "NOTE_RATE"."INSTITUTION_NUMBER"
AND "NOTE_ACCT"."NOTE_NUMBER" = "NOTE_RATE"."NOTE_NUMBER"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "NOTE_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "NOTE_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "NOTE_ACCT"."NOTE_NUMBER"
) LEFT OUTER JOIN (
"SAV_ACCT" "SAV_ACCT" WITH (NOLOCK)
INNER JOIN "SAV_INTEREST" "SAV_INTEREST" WITH (NOLOCK)
ON "SAV_ACCT"."INSTITUTION_NUMBER" = "SAV_INTEREST"."INSTITUTION_NUMBER"
AND "SAV_ACCT"."SAV_ACCOUNT" = "SAV_INTEREST"."SAV_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "SAV_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "SAV_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "SAV_ACCT"."SAV_ACCOUNT"
) LEFT OUTER JOIN "CIF_NAME" "CIF_NAME" WITH (NOLOCK)
ON "T13"."INSTITUTION_NUMBER" = "CIF_NAME"."INSTITUTION_NUMBER"
AND "T13"."NAME_ID" = "CIF_NAME"."NAME_ID"
) LEFT OUTER JOIN (
SELECT
"TAX_NAME_CROSS_APPLICATION"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"TAX_NAME_CROSS_APPLICATION"."NAME_ID" AS "NAME_ID"
,"TAX_NAME_CROSS_APPLICATION"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"TAX_NAME_CROSS_APPLICATION"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
,"TAX_NAME_CROSS_APPLICATION"."NAME_LINE" AS "NAME_LINE"
FROM "NAME_TO_ALL_ACCT" "TAX_NAME_CROSS_APPLICATION" WITH (NOLOCK)
WHERE "TAX_NAME_CROSS_APPLICATION"."STATEMENT_FLAG" = 'N'
AND "TAX_NAME_CROSS_APPLICATION"."NAME_LINE" = 0
) "TAX_NAME_CROSS_APPLICATION"
ON "T13"."INSTITUTION_NUMBER" = "TAX_NAME_CROSS_APPLICATION"."INSTITUTION_NUMBER"
AND "T13"."NAME_ID" = "TAX_NAME_CROSS_APPLICATION"."NAME_ID"
AND "T13"."ACCOUNT_NUMBER" = "TAX_NAME_CROSS_APPLICATION"."ACCOUNT_NUMBER"
AND "T13"."APPLICATION_TYPE_CODE" = "TAX_NAME_CROSS_APPLICATION"."APPLICATION_TYPE_CODE"
) LEFT OUTER JOIN "CROSS_APP" "CROSS_APP" WITH (NOLOCK)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "CROSS_APP"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "CROSS_APP"."ACCOUNT_NUMBER"
AND "CIS_ATTACHED_ACCTS"."PORTFOLIO" = "CROSS_APP"."PORTFOLIO"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "CROSS_APP"."ACCOUNT_TYPE"
WHERE
CASE WHEN NOT "TAX_NAME_CROSS_APPLICATION"."NAME_LINE" IS NULL
THEN 'Y'
ELSE 'N'
END = 'Y'
GROUP BY "CIF_NAME"."NAME_ID"
) "T0",
(
SELECT
"CIF_NAME"."NAME_ID" AS "C0"
,"CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" AS "C1"
,"CIS_ATTACHED_ACCTS"."PORTFOLIO" AS "C2"
,"CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" AS "C3"
,"CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" AS "C4"
,"CROSS_APP"."DATE_CLOSED" AS "C5"
,"CROSS_APP"."DATE_OPENED" AS "C6"
,"CROSS_APP"."CLOSED_ACCOUNT_FLAG" AS "C7"
,"CROSS_APP"."CLASS_CODE" AS "C8"
,"CROSS_APP"."PRODUCT_NUMBER" AS "C9"
,"CROSS_APP"."DATE_LAST_UPDATED" AS "C10"
,"CROSS_APP"."ACCOUNT_BALANCE" AS "C11"
,"CROSS_APP"."CMTD_AVERAGE_BALANCE" AS "C12"
,"CROSS_APP"."CYTD_AVERAGE_BALANCE" AS "C13"
,"DDA_INTEREST"."EFFECTIVE_INTEREST_RATE" AS "C14"
,"SAV_INTEREST"."EFFECTIVE_INTEREST_RATE" AS "C15"
,"COD_INTEREST"."EFFECTIVE_INTEREST_RATE" AS "C16"
,"NOTE_RATE"."RATE_OVER_SPLIT" AS "C17"
FROM ((((((("CIS_ATTACHED_ACCTS" "CIS_ATTACHED_ACCTS" WITH (NOLOCK)
INNER JOIN (
SELECT
"T1"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"T1"."NAME_ID" AS "NAME_ID"
,"CROSS_APPLICATION_NAME_TO_PORT"."PORTFOLIO" AS "PORTFOLIO"
,"T1"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
FROM (
SELECT
"T1"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"T1"."NAME_ID" AS "NAME_ID"
,"T1"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
,"T1"."PORT_SEQUENCE_NUMBER" AS "PORT_SEQUENCE_NUMBER"
,MIN("T1"."DATE_CREATED") AS "DATE_CREATED"
FROM "NAME_TO_ALL_ACCT" "T1" WITH (NOLOCK)
GROUP BY "T1"."INSTITUTION_NUMBER"
,"T1"."NAME_ID"
,"T1"."ACCOUNT_NUMBER"
,"T1"."APPLICATION_TYPE_CODE"
,"T1"."PORT_SEQUENCE_NUMBER"
) "T1", "NAME_TO_PORT" "CROSS_APPLICATION_NAME_TO_PORT" WITH (NOLOCK)
WHERE "T1"."INSTITUTION_NUMBER" = "CROSS_APPLICATION_NAME_TO_PORT"."INSTITUTION_NUMBER"
AND "T1"."NAME_ID" = "CROSS_APPLICATION_NAME_TO_PORT"."NAME_ID"
AND "CROSS_APPLICATION_NAME_TO_PORT"."RELATIONSHIP_CODE" IN (90, 91)
) "T13"
ON "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "T13"."ACCOUNT_NUMBER"
AND "CIS_ATTACHED_ACCTS"."PORTFOLIO" = "T13"."PORTFOLIO"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "T13"."APPLICATION_TYPE_CODE"
AND "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "T13"."INSTITUTION_NUMBER"
) LEFT OUTER JOIN (
"COD_ACCT" "COD_ACCT" WITH (NOLOCK)
INNER JOIN "COD_INTEREST" "COD_INTEREST" WITH (NOLOCK)
ON "COD_ACCT"."INSTITUTION_NUMBER" = "COD_INTEREST"."INSTITUTION_NUMBER"
AND "COD_ACCT"."COD_ACCOUNT" = "COD_INTEREST"."COD_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "COD_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "COD_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "COD_ACCT"."COD_ACCOUNT"
) LEFT OUTER JOIN (
"DDA_ACCT" "DDA_ACCT" WITH (NOLOCK)
INNER JOIN "DDA_INTEREST" "DDA_INTEREST" WITH (NOLOCK)
ON "DDA_ACCT"."INSTITUTION_NUMBER" = "DDA_INTEREST"."INSTITUTION_NUMBER"
AND "DDA_ACCT"."DDA_ACCOUNT" = "DDA_INTEREST"."DDA_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "DDA_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "DDA_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "DDA_ACCT"."DDA_ACCOUNT"
) LEFT OUTER JOIN (
"NOTE_ACCT" "NOTE_ACCT" WITH (NOLOCK)
INNER JOIN "NOTE_RATE" "NOTE_RATE" WITH (NOLOCK)
ON "NOTE_ACCT"."INSTITUTION_NUMBER" = "NOTE_RATE"."INSTITUTION_NUMBER"
AND "NOTE_ACCT"."NOTE_NUMBER" = "NOTE_RATE"."NOTE_NUMBER"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "NOTE_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "NOTE_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "NOTE_ACCT"."NOTE_NUMBER"
) LEFT OUTER JOIN (
"SAV_ACCT" "SAV_ACCT" WITH (NOLOCK)
INNER JOIN "SAV_INTEREST" "SAV_INTEREST" WITH (NOLOCK)
ON "SAV_ACCT"."INSTITUTION_NUMBER" = "SAV_INTEREST"."INSTITUTION_NUMBER"
AND "SAV_ACCT"."SAV_ACCOUNT" = "SAV_INTEREST"."SAV_ACCOUNT"
)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "SAV_ACCT"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "SAV_ACCT"."ACCOUNT_TYPE"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "SAV_ACCT"."SAV_ACCOUNT"
) LEFT OUTER JOIN "CIF_NAME" "CIF_NAME" WITH (NOLOCK)
ON "T13"."INSTITUTION_NUMBER" = "CIF_NAME"."INSTITUTION_NUMBER"
AND "T13"."NAME_ID" = "CIF_NAME"."NAME_ID"
) LEFT OUTER JOIN (
SELECT
"TAX_NAME_CROSS_APPLICATION"."INSTITUTION_NUMBER" AS "INSTITUTION_NUMBER"
,"TAX_NAME_CROSS_APPLICATION"."NAME_ID" AS "NAME_ID"
,"TAX_NAME_CROSS_APPLICATION"."ACCOUNT_NUMBER" AS "ACCOUNT_NUMBER"
,"TAX_NAME_CROSS_APPLICATION"."APPLICATION_TYPE_CODE" AS "APPLICATION_TYPE_CODE"
,"TAX_NAME_CROSS_APPLICATION"."NAME_LINE" AS "NAME_LINE"
FROM "NAME_TO_ALL_ACCT" "TAX_NAME_CROSS_APPLICATION" WITH (NOLOCK)
WHERE "TAX_NAME_CROSS_APPLICATION"."STATEMENT_FLAG" = 'N'
AND "TAX_NAME_CROSS_APPLICATION"."NAME_LINE" = 0
) "TAX_NAME_CROSS_APPLICATION"
ON "T13"."INSTITUTION_NUMBER" = "TAX_NAME_CROSS_APPLICATION"."INSTITUTION_NUMBER"
AND "T13"."NAME_ID" = "TAX_NAME_CROSS_APPLICATION"."NAME_ID"
AND "T13"."ACCOUNT_NUMBER" = "TAX_NAME_CROSS_APPLICATION"."ACCOUNT_NUMBER"
AND "T13"."APPLICATION_TYPE_CODE" = "TAX_NAME_CROSS_APPLICATION"."APPLICATION_TYPE_CODE"
) LEFT OUTER JOIN "CROSS_APP" "CROSS_APP" WITH (NOLOCK)
ON "CIS_ATTACHED_ACCTS"."INSTITUTION_NUMBER" = "CROSS_APP"."INSTITUTION_NUMBER"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_NUMBER" = "CROSS_APP"."ACCOUNT_NUMBER"
AND "CIS_ATTACHED_ACCTS"."PORTFOLIO" = "CROSS_APP"."PORTFOLIO"
AND "CIS_ATTACHED_ACCTS"."ACCOUNT_TYPE" = "CROSS_APP"."ACCOUNT_TYPE"
WHERE
CASE WHEN NOT "TAX_NAME_CROSS_APPLICATION"."NAME_LINE" IS NULL
THEN 'Y'
ELSE 'N'
END = 'Y'
) "T1"
LEFT JOIN CIS_Codes WITH (NOLOCK)
ON "T1"."C1" = CIS_Codes.Institution_Number
AND "T1"."C2" =CIS_Codes.Portfolio
WHERE "T1"."C0" = "T0"."C0"
OR "T1"."C0" IS NULL
AND "T0"."C0" IS NULL
GROUP BY
"T1"."C1"
,"T1"."C2"
,"T1"."C3"
,"T1"."C4"
,"T1"."C5"
,"T1"."C6"
,"T1"."C7"
,"T1"."C8"
,"T1"."C9"
,"T1"."C10"
,"T1"."C0"
,"T0"."C1"
,"T0"."C2"
,CIS_Codes.Date_Last_Updated
Thanks,
Sam
August 29, 2017 at 5:42 am
Not that I know of. Searching for FROM won't find JOINed tables, by the way.
Formatting your query better would make things a lot clearer:
1) Remove quotes
2) Use aliases
3) Use a code formatting tool (and post SQL here in IF tags)
Finally, did you advise your users that the results returned by the query may contain duplicate rows, data from uncommitted transactions and may exclude certain other rows, as a result of using NOLOCK everywhere?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
August 29, 2017 at 6:16 am
NOLOCK is used for peformance sake to avoid blockings. Again, its a business decision and we are just vendors. This is a typical Warehouse system and once data loaded to staging area, the assumption is that, it does gets changed. Data is loaded only once and kept unchanged. On top of it, users or ETL packages reads data from those table.
Also, currently I am using a tool called poorsql. (http://poorsql.com/) for formatting SQL queries.
Just looking for a tool to extract the tables from the given query.
Thank you.
August 29, 2017 at 6:58 am
If it's available, you can easily shred the XML query plan for the SQL statement to find any referenced tables.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 29, 2017 at 8:11 am
Duplicate on MSDN forums: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1e5f20af-b69e-4c72-bdeb-de99d67ec949/any-simple-tool-or-query-to-find-out-all-the-tables-in-a-query-?forum=sqldatabaseengine
It doesn't appear that the OP is actually interested in an answer...
Alan H
MCSE - Data Management and Analytics
Senior SQL Server DBA
Best way to ask a question: http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 29, 2017 at 2:41 pm
SQL_Hacker - Tuesday, August 29, 2017 8:11 AMDuplicate on MSDN forums: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1e5f20af-b69e-4c72-bdeb-de99d67ec949/any-simple-tool-or-query-to-find-out-all-the-tables-in-a-query-?forum=sqldatabaseengine
It doesn't appear that the OP is actually interested in an answer...
A lot of posters do that. But after you posted this, one of the posts on msdn is marked as an answer.
Use the query to create a view and then view the dependencies for that view.
Sue
August 29, 2017 at 3:36 pm
Create view and run the below query to get the dependent objects
SELECT DISTINCT referenced_entity_name
FROM sys.dm_sql_referenced_entities('dbo.' + @viewname, 'OBJECT') ref
WHERE referenced_entity_name IS NOT NULL
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply