Monday, April 18, 2011

Get extended properties of a table and columns? Easy.

Want to get the DESCRIPTION and other extended features of the table GATO1? easy:
select xp.name, cast(xp.[value] as nvarchar(4000)), cast(SQL_VARIANT_PROPERTY(xp.[value], 'BaseType') as nvarchar(256)), cast(SQL_VARIANT_PROPERTY(xp.[value], 'MaxLength') as int), cast(SQL_VARIANT_PROPERTY(xp.[value], 'Precision') as int), cast(SQL_VARIANT_PROPERTY(xp.[value], 'Scale') as int), xp.minor_id, COL_NAME(xp.major_id, xp.minor_id)  from sys.extended_properties xp  where xp.class = 1 and  xp.minor_id > 0 and xp.major_id = object_id(N'dbo.GATO1')  and xp.name in (N'MS_Description')  order by xp.minor_id
Results:

No comments:

Post a Comment