Wednesday, 25 April 2018

How I find a particular column name within all tables of SQL server database?

Find a particular column name within all tables of SQL server database.

select * from information_schema.columns
where column_name like '%employee_id%'



Find a particular column name and datatype details within all tables of SQL server database.

SELECT
OBJECT_NAME(c.OBJECT_ID) TableName
,c.name AS ColumnName
,SCHEMA_NAME(t.schema_id) AS SchemaName
,t.name AS TypeName
,t.is_user_defined
,t.is_assembly_type
,c.max_length
,c.PRECISION
,c.scale
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id where c.name like '%family_id%'

ORDER BY c.OBJECT_ID;

No comments:

Post a Comment