Is there an easy way (a sql script) to drop the "MS_Description" of all tables and all columns in my database?
Regards,
Alejandroo
These queries will produce a script that you can run to drop these properties. You can automate with a cursor, or you might want to add a GO to the end of each EXEC statement.
--tables
select 'EXEC sp_dropextendedproperty
@.name = ''MS_Description''
,@.level0type = ''schema''
,@.level0name = ' + object_schema_name(extended_properties.major_id) + '
,@.level1type = ''table''
,@.level1name = ' + object_name(extended_properties.major_id)
from sys.extended_properties
where extended_properties.class_desc = 'OBJECT_OR_COLUMN'
and extended_properties.minor_id = 0
and extended_properties.name = 'MS_Description'
--columns
select 'EXEC sp_dropextendedproperty
@.name = ''MS_Description''
,@.level0type = ''schema''
,@.level0name = ' + object_schema_name(extended_properties.major_id) + '
,@.level1type = ''table''
,@.level1name = ' + object_name(extended_properties.major_id) + '
,@.level2type = ''column''
,@.level2name = ' + columns.name
from sys.extended_properties
join sys.columns
on columns.object_id = extended_properties.major_id
and columns.column_id = extended_properties.minor_id
where extended_properties.class_desc = 'OBJECT_OR_COLUMN'
and extended_properties.minor_id > 0
and extended_properties.name = 'MS_Description'
|||Thanks a lot Louis, this works perfectly!
No comments:
Post a Comment