檢視所有VIEW/TABLE in MSSQL
顯示某個Sql Server某個資料庫中所有表或檢視的資訊
sql server 2000 與 2005 不同 差別在於 紅色字部分
以下語句為獲取所有表資訊,替換綠色黑體字"U"為"V"為獲取所有檢視資訊。
Sql Server 2000 版本
SELECT Sysobjects.name AS TABLE_NAME, syscolumns.Id, syscolumns.name AS COLUMN_NAME,
systypes.name AS DATA_TYPE, syscolumns.length as CHARACTER_MAXIMUM_LENGTH,
sysproperties.[value] AS COLUMN_DESCRIPTION, syscomments.text as
COLUMN_DEFAULT,syscolumns.isnullable as IS_NULLABLE FROM syscolumns
INNER JOIN systypes
ON syscolumns.xtype = systypes.xtype
LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id
LEFT OUTER JOIN sysproperties ON
( sysproperties.smallid = syscolumns.colid
AND sysproperties.id = syscolumns.id)
LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id
WHERE syscolumns.id IN
(SELECT id FROM SYSOBJECTS WHERE xtype = 'U') AND (systypes.name <> 'sysname')
ORDER BY syscolumns.colid
Sql Server 2005版本
SELECT Sysobjects.name AS TABLE_NAME, syscolumns.Id, syscolumns.name AS COLUMN_NAME,
systypes.name AS DATA_TYPE, syscolumns.length as CHARACTER_MAXIMUM_LENGTH,
sys.extended_properties.[value] AS COLUMN_DESCRIPTION, syscomments.text as
COLUMN_DEFAULT,syscolumns.isnullable as IS_NULLABLE FROM syscolumns
INNER JOIN systypes
ON syscolumns.xtype = systypes.xtype
LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id
LEFT OUTER JOIN sys.extended_properties ON
( sys.extended_properties.minor_id = syscolumns.colid
AND sys.extended_properties.major_id = syscolumns.id)
LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id
WHERE syscolumns.id IN
(SELECT id FROM SYSOBJECTS WHERE xtype = 'U') AND (systypes.name <> 'sysname')
ORDER BY syscolumns.colid
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8337095/viewspace-1049478/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MSSQL索引檢視(indexed view)之簡述及使用SQL索引IndexView
- MySQL View 檢視MySqlView
- materialized view (物化檢視)ZedView
- Mac 檢視所有埠Mac
- git檢視所有分支Git
- MySQL View(檢視)詳解MySqlView
- postgresql如何檢視所有表SQL
- 建立物化檢視MV ( Materialized View )ZedView
- ThinkPHP框架檢視詳細介紹View檢視–模板(九)PHP框架View
- 在列印視窗,列印檢視View的子檢視結構圖View
- view the favorites table.View
- Git檢視所有tag標籤Git
- redis如何檢視所有的keyRedis
- hive中的 lateral view(側檢視)HiveView
- android 動畫 ——檢視動畫(View Animation)Android動畫View
- View Transform(檢視變換)詳解ViewORM
- 檢視合併(View Merging)View
- 轉:物化檢視(Materialized View)介紹ZedView
- Dataguard (Standby) 相關的檢視(View)View
- 使用 on prebuilt table 建立物化檢視 (ZT)UI
- 使用 on prebuilt table 建立物化檢視(zt)UI
- 檢視所有已安裝的Patch
- mssql bcp 工具用法和檢視角色儲存過程SQL儲存過程
- laravel利用artisan建立view檢視檔案LaravelView
- oracle parallel並行及px檢視viewOracleParallel並行View
- 對資料庫檢視view的理解資料庫View
- 檢視SAP使用者的IP[table]
- linux下檢視埠是否被佔用以及檢視所有埠Linux
- linux檢視所有使用者Linux
- 檢視linux中所有的服務Linux
- nancy Unable to find view engine that could render the view 無法找到檢視模板引擎NaNView
- 小程式開發基礎-view檢視容器View
- oracle10g materialized view物化檢視示例OracleZedView
- ogg 同步 物化檢視建立限制 Materialized ViewZedView
- sql 2005 跟據檢視名列出檢視所有列的描述SQL
- 【實驗】【檢視】使用v$bgprocess檢視獲得所有後臺程式資訊
- 利用檢視 V$FIXED_VIEW_DEFINITION 可以檢視Oracle很多底層的東西ViewOracle
- sql檢視所有表空間使用情況SQL