• Sql Server 添加、更新、查询表注释、字段注释相关sql



    /*******************字段添加注释*********************/ if not exists (SELECT C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id INNER JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id WHERE A.name = N'表名' and B.name=N'字段名') EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字段注释' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'表名', @level2type=N'COLUMN',@level2name=N'字段名' EXEC sp_updateextendedproperty @name=N'MS_Description', @value=N'字段注释' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'表名', @level2type=N'COLUMN',@level2name=N'字段名' /*******************表添加注释*********************/ if not exists (SELECT A.name, C.value FROM sys.tables A inner JOIN sys.extended_properties C ON C.major_id = A.object_id and minor_id=0 WHERE A.name = N'表名') EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表注释' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'表名' EXEC sp_updateextendedproperty @name=N'MS_Description', @value=N'表注释' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'表名' /*******************查询注释相关sql***********************/ --查看表的注释 SELECT A.name, C.value FROM sys.tables A inner JOIN sys.extended_properties C ON C.major_id = A.object_id and minor_id=0 WHERE A.name = N'表名' --查看字段的注释 SELECT A.name AS table_name, B.name AS column_name, C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id WHERE A.name = N'luobo'

      

  • 相关阅读:
    【日常学习】codevs1287 矩阵乘法题解
    数据库系统概论-[04]索引
    oracle-sql分析练习
    大水题(容斥原理)
    大水题(容斥原理)
    hdu 2952 Counting Sheep
    hdu 2952 Counting Sheep
    HDU 2612 Find a way
    HDU 2612 Find a way
    hdu 2181 哈密顿绕行世界问题
  • 原文地址:https://www.cnblogs.com/straw/p/5964899.html
Copyright © 2020-2023  润新知