一些有用的SQL语句搜集整理

SQL Server 2000 里查询得到当前数据库的所有数据表名
select * from sysobjects where objectproperty(id,'isusertable')=1 order by name sp_tables
select * from INFORMATION_SCHEMA.TABLES
select * from sysobjects where objectproperty(id,'isusertable')=1 order by name
select * from sysobjects where xtype='U' 以上会查出dtproperties表(作用是存储数据库的关系图) select * from sysobjects where xtype='U' and status>0
获得各个用户表之间关联关系的SQL
select object_name(A.parent_obj) as 表名 ,col_name(A.parent_obj,B.fkey) as 列名 ,object_name(B.rkeyid) as 引用表名 ,col_name(B.rkeyid,B.rkey) as 引用列名 from sysobjects A join sysforeignkeys B on A.id=B.constid

 

posted @ 2007-05-17 21:39  jun.ma  阅读(133)  评论(0编辑  收藏  举报