use
[Database]
GO
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS
schema_name,
c.name AS
column_name
FROM sys.tables AS t
INNER JOIN
sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%selling%'
ORDER BY
schema_name,
table_name;
--Also could do the same for views by querying sys.views:
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.views AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%_productcodetypeidname%'
ORDER BY schema_name, table_name;
-- find all occurrences in stored procs
select top 10 * from sys.syscomments where text like '%Fact_Purchase_Order%'
-- find all occurrences in objects , views, etc,
SELECT
referencing_schema_name = SCHEMA_NAME(o.SCHEMA_ID),
referencing_object_name = o.name,
referencing_object_type_desc = o.type_desc,
referenced_schema_name,
referenced_object_name = referenced_entity_name,
referenced_object_type_desc = o1.type_desc,
referenced_server_name, referenced_database_name
--,sed.* -- Uncomment for all the columns
FROM
sys.sql_expression_dependencies sed
INNER JOIN
sys.objects o ON sed.referencing_id = o.[object_id]
LEFT OUTER JOIN
sys.objects o1 ON sed.referenced_id = o1.[object_id]
WHERE
referenced_entity_name like '%Fact_Purchase_Order%'
--Also could do the same for views by querying sys.views:
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.views AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%_productcodetypeidname%'
ORDER BY schema_name, table_name;
-- find all occurrences in stored procs
select top 10 * from sys.syscomments where text like '%Fact_Purchase_Order%'
-- find all occurrences in objects , views, etc,
SELECT
referencing_schema_name = SCHEMA_NAME(o.SCHEMA_ID),
referencing_object_name = o.name,
referencing_object_type_desc = o.type_desc,
referenced_schema_name,
referenced_object_name = referenced_entity_name,
referenced_object_type_desc = o1.type_desc,
referenced_server_name, referenced_database_name
--,sed.* -- Uncomment for all the columns
FROM
sys.sql_expression_dependencies sed
INNER JOIN
sys.objects o ON sed.referencing_id = o.[object_id]
LEFT OUTER JOIN
sys.objects o1 ON sed.referenced_id = o1.[object_id]
WHERE
referenced_entity_name like '%Fact_Purchase_Order%'