SQL Server 的所有表查詢和注釋說明查詢

2021-08-01 03:04:53 字數 504 閱讀 8785

學習sql server時,用到了2條特殊查詢語句,特意來記錄一下,一是查詢資料庫中所有的資料庫表,二是查詢資料庫表中的說明字段

1、查詢資料庫中所有的資料庫表

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

2、查詢資料庫表中的說明字段

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 ='填需要查詢的表的表名

SQLserver查詢所有表和表下面所有列

select case when a.colorder 1 then d.name else null end 表名,a.colorder 字段序號,a.name 欄位名,case when columnproperty a.id,a.name,isidentity 1 then else end ...

sqlserver 查詢所有表及記錄行數

查詢所有表名 select name from sysobjects where xtype u select from sys.tables 查詢所有表名及對應架構 select t.name as tablename,s.name as schema from sys.tables as t,s...

sql server 查詢某個表的所有觸發器名稱

查出所有用到某個表的sql select from sysobjects where xtype tr select from sysobjects where xtype tr and parent obj object id 表名 xtype char 2 物件型別。可以是下列物件型別中的一種 ...