I've been doing a lot of querying lately for a DB that I'm not that familiar, I would like to take note of helpful scripts I often used to analyze db structure.
Find column name
1
2
3
4
5
6
7
| 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;
|
Find table name
1
2
3
| SELECT *
FROM sys.Tables
WHERE name LIKE '%Address%'
|
Find SP name
1
2
3
| select *
from sys.procedures
where name like '%name_of_proc%'
|
Comments