读书人

怎么找出字段默认值名称

发布时间: 2012-01-15 22:57:49 作者: rapoo

如何找出字段默认值名称?
select name as dropname from sysobjects where xtype= 'D ' and parent_obj=(select id from sysobjects where name= 'table_name ' and xtype= 'U ') and id in (select cdefault from syscolumns where name= 'column_nane ')

我是这样写的,执行结果没问题,大家有没有更好的方法?

[解决办法]
select name as dropname from sysobjects where xtype= 'D ' and id=(select cdefault from syscolumns where name= 'column_nane ' and object_id( 'tablename ')=id)

读书人网 >SQL Server

热点推荐