列出目前SQL Server 中資料庫相關的資訊
1.取得資料庫數量
select count(*) as totaltablenumber from sysobjects where xtype = 'U';
2.取得資料表名稱(tablename)及欄位數量(columnnumber)
select name as tablename, info as columnnumber from sysobjects where xtype = 'U';
3.取得某一資料表內所有欄位名稱
select b.name from sysobjects as a, syscolumns as b where a.xtype = 'U' and a.id = b.id and a.name='資料表單名稱';
3.1 取得某一資料表內所有欄位名稱EXEC sp_columns 表單名稱
==========================================================================
USE master
SELECT dbid, DB_NAME(dbid) AS DB_NAMEFROM sysdatabasesORDER BY dbid
select count(*) as totaltablenumber from sysobjects where xtype = 'U';
2.取得資料表名稱(tablename)及欄位數量(columnnumber)
select name as tablename, info as columnnumber from sysobjects where xtype = 'U';
3.取得某一資料表內所有欄位名稱
select b.name from sysobjects as a, syscolumns as b where a.xtype = 'U' and a.id = b.id and a.name='資料表單名稱';
3.1 取得某一資料表內所有欄位名稱EXEC sp_columns 表單名稱
==========================================================================
USE master
SELECT dbid, DB_NAME(dbid) AS DB_NAMEFROM sysdatabasesORDER BY dbid