Tag Archives: SQL related

Get the default value of the field

Get all default values:
Select * from syscolumns c inner join systypes t on c.xusertype=t.xusertype left syscolumns c inner join syscolumns t on c.xusertype=t.xusertype left Join sysproperties p on c.id=p.id and c.colid = p.mallid left join syscomments m on c.default =m.id
 
Get the default value of a single field:
Select * from syscolumns c inner join systypes t on c.xusertype=t.xusertype left syscolumns c inner join syscolumns t on c.xusertype=t.xusertype left Join sysproperties p on c.id=p.id and c.colid = p.mallid left join syscomments m on c.default =m.id where objectProperty (c.id,’IsUserTable’)=1 and object_name(c.id) = ‘T_good’ and objectProperty (c.id) = ‘T_good’ and C.name = ‘field name’