sql server 檢視字段備註等資訊

2021-07-11 05:28:20 字數 3399 閱讀 8002

select     d.name as 英文表名, isnull(h.value, n'') as 中文表名, 

a.colorder as 字段序號, a.name as 英文列名, isnull(g.value, n'') 

as 中文列名, case when columnproperty(a.id, a.name, 'isidentity') = 1 then '√' else '' end as 標識列, 

case when a.isnullable = 1 then '√' else '' end as 允許空, case when columnproperty(a.id, a.name, 'iscomputed') = 1 then '√' else '' end as 計算列, 

case when exists

(select     1

from          dbo.sysindexes si(readpast) inner join

dbo.sysindexkeys sik(readpast) on si.id = sik.id and si.indid = sik.indid inner join

dbo.syscolumns sc(readpast) on sc.id = sik.id and sc.colid = sik.colid inner join

dbo.sysobjects so(readpast) on so.name = si.name and so.xtype = 'pk'

where      sc.id = a.id and sc.colid = a.colid) then '√' else '' end as 主鍵, isnull

((select     top (1) definition

from         sys.check_constraints with (readpast)

where     (parent_object_id = d.id) and (parent_column_id = a.colid)), n'') as check約束, isnull(e.text, n'') as 預設值, isnull

((select     top (1) cx.name

from         sys.syscolumns as ax with (readpast) inner join

sys.sysobjects as bx with (readpast) on ax.id = bx.id inner join

sys.sysobjects as cx with (readpast) on ax.domain = cx.id

where     (d.id = bx.id) and (a.colid = ax.colid)), n'') as 繫結規則, isnull

((select     top (1) ee.name

from         sys.foreign_key_columns as aa with (readpast) inner join

sys.syscolumns as bb with (readpast) on aa.parent_column_id = bb.colid inner join

sys.sysobjects as cc with (readpast) on aa.parent_object_id = cc.id and bb.id = cc.id inner join

sys.syscolumns as dd with (readpast) on aa.referenced_column_id = dd.colid inner join

sys.sysobjects as ee with (readpast) on aa.referenced_object_id = ee.id and dd.id = ee.id

where     (bb.colid = a.colid) and (cc.id = d.id)), n'') as 參照表, isnull

((select     top (1) dd.name

from         sys.foreign_key_columns as aa with (readpast) inner join

sys.syscolumns as bb with (readpast) on aa.parent_column_id = bb.colid inner join

sys.sysobjects as cc with (readpast) on aa.parent_object_id = cc.id and bb.id = cc.id inner join

sys.syscolumns as dd with (readpast) on aa.referenced_column_id = dd.colid inner join

sys.sysobjects as ee with (readpast) on aa.referenced_object_id = ee.id and dd.id = ee.id

where     (bb.colid = a.colid) and (cc.id = d.id)), n'') as 參照列, b.name as 型別, a.length as 長度, columnproperty(a.id, a.name, 'precision') as 精度, 

isnull(columnproperty(a.id, a.name, 'scale'), 0) as 小數字數, d.crdate as 建立時間, case when a.colorder = 1 then d .refdate else null 

end as 更改時間

from         dbo.syscolumns as a with (readpast) left outer join

dbo.systypes as b with (readpast) on a.xtype = b.xusertype inner join

dbo.sysobjects as d with (readpast) on a.id = d.id and d.xtype = 'u' and d.name not in ('sysdiagrams') and d.status >= 0 left outer join

dbo.syscomments as e with (readpast) on a.cdefault = e.id left outer join

sys.extended_properties as g with (readpast) on a.id = g.major_id and a.colid = g.minor_id and g.name = 'ms_description' left outer join

sys.extended_properties as h with (readpast) on a.id = h.major_id and 0 = h.minor_id and h.name = 'ms_description'

sqlserver給表加備註並檢視

一 給表加備註語句 比如給乙個叫test的表加乙個備註叫 測試 exec sys.sp addextendedproperty name n ms description level0type n schema level0name n dbo level1type n table 上述為系統寫死的...

sql server如何檢視字段型別

要檢視sql server表中的字段型別,有以下兩種方案 1 通過sql server management studio進行檢視。找到表的 開啟 之後再找到我們建立的表,找到 開啟。然後找到列名 開啟就可以看到字段型別。如下圖 2 通過sql指令進行檢視 select name as column...

mysql中備註字段 訪問中的備註字段

mysql中備註字段 由於在醫療保健領域工作,我使用了大量的備忘字段 我們非常重視progress notes等。因此,我一直在尋找有關該主題的任何內容。以下是我在過去幾年中獲得的東西的摘要。為了給您乙個想法,我將其儲存在名為memofieldangst的檔案中!使用distinct或distinc...