sql server 2000 系统表应用

--1:获取当前数据库中的所有用户表
select Name from sysobjects where xtype='u' and status>=0 
--2:获取某一个表的所有字段
select * from syscolumns where id=object_id('test1') 
--3:查看与某一个表相关的视图、存储过程、函数
select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%' 
--4:查看当前数据库中所有存储过程
select name as 存储过程名称 from sysobjects where xtype='P' 
--5:查询用户创建的所有数据库
select * from master..sysdatabases D where sid not in(select sid from master..syslogins where name='sa') 或者
select dbid, name AS DB_NAME from master..sysdatabases where sid <> 0x01
--6:查询某一个表的字段、数据类型和字段长度
select column_name,data_type ,character_octet_length from information_schema.columns where table_name = 'test1' 
select column_name,data_type ,character_octet_length from information_schema.columns where table_name = 'test2' 

  

posted @ 2013-02-19 13:01  qingsong_do  阅读(192)  评论(0编辑  收藏  举报