执行sql
select  o.name,cl.name,cm.text from sysobjects o,syscolumns cl, syscomments cm
 where o.id = cl.id and cl.cdefault = cm.id  and o.type='U'
  and o.name='test2' and cl.name like 'col%'
 
test2是标明, col%是列名通配符, 'U' 表示表格是用户表
 
返回结果:
 
name                           name                           text                                                                                                                                                                                                                                                            
----                           ----                           ----                                                                                                                                                                                                                                                            
test2                          col1                           DEFAULT (0)                                                                                                                                                                                                                                                     
test2                          col2                           DEFAULT  2                                                                                                                                                                                                                                                      
test2                          col3                           DEFAULT  getdate()            
 
 
syscolumns 中 id 表示对应的表格在sysobjects中id, cdefault表示在syscomments中的缺省值注释id
 
 
缺省值可能会出现函数, 例如  default getdate(),
所以我觉得应该这个缺省值可以剥离掉default, 如果使用hibernate实现,还只能用dynamic insert,dynamic update.
 
 
文章来源:
http://stocknewbie.bokee.com/viewdiary.31463433.html
	posted on 2009-05-01 10:52 
huohuo 阅读(499) 
评论(0)  编辑  收藏