当前位置:网站首页>All table queries and comment description queries of SQL Server

All table queries and comment description queries of SQL Server

2022-04-23 19:08:00 Little brother

Study SQL Server when , Yes 2 Special query statement , I'd like to record it , One is to query all database tables in the database , The second is to query the description field in the database table

1、 Query all the database tables in the database

select * from sysobjects where xtype = 'u' and name != 'sysdiagrams'


2、 Query the description field in the database table

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 =' Fill in the table name of the table to be queried

版权声明
本文为[Little brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210601423207.html