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 表單名稱
4.另外3的話不會照欄位順序排,請加入: order by b.colorder
5.取得資料庫所有資料表名稱
select * from sysobjects where xtype = 'U'
 
以上為SQL 2000 OK 2005請使用下列語法
 
6.在SQL SERVER 2005抓取資料庫的SQL語法

select name from master.dbo.sysdatabases

7.抓取資料表的SQL語法

select Table_name from INFORMATION_SCHEMA.TABLES order by Table_name

8.抓取欄位的SQL語法
select column_name from INFORMATION_SCHEMA.COLUMNS where table_name='TableName'

文章標籤
全站熱搜
創作者介紹
創作者 None 的頭像
None

Record

None 發表在 痞客邦 留言(0) 人氣(0)