• 如何清除sql2005中字段的字段备注信息?(downmoon)


    如何清除sql2005中字段的字段备注信息?(downmoon)
    比如一个表t1,
    字段tID int Primary Int 字段说明 '主键'
    字段tName nvarchar(100) 字段说明 '名称'
    字段tTime nvarchar(100) 字段说明 '创建时间'
    字段tState nvarchar(100) 字段说明 '当前状态'

    现在想清除字段的备注信息,如“主键”、“名称”、“创建时间”等

    select * from sys.extended_properties 
    where [name]='MS_Description'

    这条语句只能查看, 不能删除或更新
    delete from sys.extended_properties where [name]='MS_Description'
    update sys.extended_properties  set [value]='' where [name]='MS_Description'

    上面两句均出错! 提示:
    消息 259,级别 16,状态 1,第 1 行
    不允许对系统目录进行即席更新。


    后来在微软网站查得结果
    http://technet.microsoft.com/zh-cn/library/ms178595.aspx
    示例
    A. 删除列上的扩展属性

    以下示例从架构 dbo 内包含的表 T1 中的列 id 上删除属性 'caption'。

    CREATE TABLE T1 (id int , name char (20));
    GO
    EXEC sp_addextendedproperty 
        @name = 'caption' 
        ,@value = 'Employee ID' 
        ,@level0type = 'schema' 
        ,@level0name = dbo
        ,@level1type = 'table'
        ,@level1name = 'T1'
        ,@level2type = 'column'
        ,@level2name = id;
    GO
    EXEC sp_dropextendedproperty 
         @name = 'caption' 
        ,@level0type = 'schema' 
        ,@level0name = dbo
        ,@level1type = 'table'
        ,@level1name = 'T1'
        ,@level2type = 'column'
        ,@level2name = id;
    GO
    DROP TABLE T1;
    GO

    B. 删除数据库中的扩展属性

    以下示例从 AdventureWorks 示例数据库中删除名为 MS_Description 的属性。由于属性位于数据库本身中,因此不指定对象类型和名称。

    USE AdventureWorks;
    GO
    EXEC sp_dropextendedproperty 
    @name = N'MS_Description';
    GO

    但以上语句无法执行,
    后来用生成的sp_addextendedproperty修改为sp_dropextendedproperty 实现

    邀月注:本文版权由邀月和博客园共同所有,转载请注明出处。
    助人等于自助!  3w@live.cn
  • 相关阅读:
    【情感计算】资源
    有意思的网站
    【NLP】新词发现
    [openwrt]网络配置
    【SSH】远程下载
    【OpenWRT】网络配置
    [SSH]连接失败
    [Openwrt]wifi桥接设置
    【Openwrt】刷
    【Python】excel
  • 原文地址:https://www.cnblogs.com/downmoon/p/1100113.html
Copyright © 2020-2023  润新知