I inherited DB admin role cuz our DB admin left. I ran the following query to find all the tables in a DB that have the same column name.
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 '%EmployeeID%'
ORDER BY schema_name, table_name;
I have two questions.
1. How can I find out how the tables are related to each other (foreign key, primary key, etc.).
2. How can I update (if I need to) all the tables from the above query.