方法1:
select object_name(parent_object_id) as tblname, c.name as columnname, c.is_nullable as allownull , s.name as consname, definition as defaultvalue
from sys.default_constraints s, sys.[columns] c
where s.parent_object_id = c.[object_id] and s.parent_column_id = c.column_id
and object_name(parent_object_id) = ‘repairbillmaster’
方法2:
SELECT SO.NAME AS tblname, SC.NAME AS columnname, SM.TEXT AS defaultvalue
FROM dbo.sysobjects SO INNER JOIN dbo.syscolumns SC ON SO.id = SC.id
LEFT JOIN dbo.syscomments SM ON SC.cdefault = SM.id
WHERE SO.xtype = ‘U’ and so.name=’repairbillmaster’ and SM.TEXT is not null
ORDER BY SO.[name], SC.colid