Sql Server2000裏面獲得數據庫裏面所有的用戶表名稱和對應表的列名稱

--1:獲取當前數據庫中的所有用戶表

select Name from sysobjects where xtype='u' and status>=0

--

select name from syscolumns where id=object_id(N'表名')

--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 from information_schema.columns
where table_name = N'表名'

--7:獲取數據庫文件路徑

select ltrim(rtrim(filename)) from 數據庫名..sysfiles where charindex('MDF',filename)>0
or
select ltrim(rtrim(filename)) from 數據庫名..sysfiles where charindex('LDF',filename)>0 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章