您的位置:首页 > 数据库

sql server 中获取字段默认值SQL

2006-09-08 10:00 309 查看
获取所有的默认值列表

select
object_name(c.id) as 表名
,c.name as 字段名
,t.name as 数据类型
,c.prec as 长度
,p.value as 字段说明
,m.text as 默认值
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

研究了很久 终于搞定了

获取单个字段的默认值列表

select
object_name(c.id) as 表名
,c.name as 字段名
,t.name as 数据类型
,c.prec as 长度
,p.value as 字段说明
,m.text as 默认值
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'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: