Love to code, although it bugs me.

MS-SQL–Get all tables with a given column name

No comments
Using Microsoft SQL Server, found this to be handy sometimes:

USE [your database name]
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 '%given column name%'
ORDER BY schema_name, table_name;

HTH.

No comments :

Post a Comment