教您如何獲取SQL字段默認(rèn)值
作者:佚名
sql server中的字段默認(rèn)值的獲取方法未必人人都會(huì),下文對(duì)獲取SQL字段默認(rèn)值的方法進(jìn)行了詳細(xì)的闡述說(shuō)明,供您參考學(xué)習(xí)。
在sql server 中,如何獲取SQL字段默認(rèn)值呢?下面就為您介紹實(shí)現(xiàn)該功能的方法,如果您遇到過(guò)類(lèi)似的問(wèn)題,不妨一看,希望對(duì)您有所幫助。
sql server 中獲取SQL字段默認(rèn)值 ,獲取所有的默認(rèn)值列表:
- select
- object_name(c.id) as 表名
- ,c.name as 字段名
- ,t.name as 數(shù)據(jù)類(lèi)型
- ,c.prec as 長(zhǎng)度
- ,p.value as 字段說(shuō)明
- ,m.text as 默認(rèn)值
- from syscolumns c
- inner join
- systypes t
- on c.xusertype=t.xusertype
- left join
- sysproperties p
- on c.id=p.id and c.colid = p.smallid
- left join
- syscomments m
- on c.cdefault=m.id
研究了很久 終于搞定了
獲取單個(gè)SQL字段默認(rèn)值列表
- select
- object_name(c.id) as 表名
- ,c.name as 字段名
- ,t.name as 數(shù)據(jù)類(lèi)型
- ,c.prec as 長(zhǎng)度
- ,p.value as 字段說(shuō)明
- ,m.text as 默認(rèn)值
- from syscolumns c
- inner join
- systypes t
- on c.xusertype=t.xusertype
- left join
- sysproperties p
- on c.id=p.id and c.colid = p.smallid
- left join
- syscomments m
- on c.cdefault=m.id
- where objectproperty(c.id,'IsUserTable')=1
- and object_name(c.id) = 'T_good' and c.name = 'ishot'
【編輯推薦】
責(zé)任編輯:段燃
來(lái)源:
CSDN博客