Friday, April 27, 2012

List All The Column With Specific Data Types



Simple script to identify all the columns with same datatype in specific database:
SELECT OBJECT_NAME(c.OBJECT_ID) TableName, c.name ColumnName
FROM sys.columns AS c
JOIN sys.types AS t ON c.user_type_id=t.user_type_id
WHERE t.name = 'text' --change text to other datatypes
ORDER BY c.OBJECT_ID;
GO

No comments:

Post a Comment