获取数据库中有默认值的所以字段

select a.name as TableName,b.name as FieldName,c.text as defaultValue
from sys.sysobjects a inner join sys.syscolumns b on a.id=b.id
inner join sys.syscomments c on b.cdefault=c.id
where a.xtype='U'
order by a.name,b.name

select a.name as TableName,b.name as FieldName,c.text as defaultValue
from sys.objects a inner join sys.columns b on a.object_id=b.object_id
inner join sys.syscomments c on b.default_object_id=c.id
order by defaultValue

posted @ 2013-07-01 16:21  空紫竹  阅读(606)  评论(0编辑  收藏  举报