获取字段默认值

来源:互联网 发布:浙江教育网络电视 编辑:程序博客网 时间:2024/03/29 09:22

获取所有默认值:

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 = '字段名称'  

 

0 0
原创粉丝点击