SQL Command:
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 表單名稱
Store Procedure:
資料庫中所有資料表:透過內定的Stored Procedure sp_tables
- EXEC sp_tables
- @table_name = '%',
- @table_owner = 'dbo',
- @table_qualifier = @DBName;
sp_columns @TableName
取得欄位說明、備註(Extended Property):這個是透過Sql內定的Function來處理
- SELECT *
- FROM ::fn_listextendedproperty(NULL, 'user', 'dbo', 'table', @TableName, 'column', default)
sp_pkeys @TableName
沒有留言:
張貼留言