用户表、表字段、外键查询

1267阅读 0评论2008-10-16 wilsonwong
分类:WINDOWS

查询所有的用户表
select * from sysobjects where xtype='U'
查询某个用户表
select * from sysobjects where xtype='U' and id=object_id('用户表名称')
 
查询表字段
select * from syscolumns where id=object_id('用户表名称')
 
查询表外键
select * from syscolumns
  where id=object_id('用户表名称')
        and
        colid in(select fkey from sysforeignkeys where fkeyid=object_id('用户表名称'))
上一篇:E电城
下一篇:存储过程的递归中使用游标的冲突问题解决方法