近來用MSSQL比較多些,而且要分析一些大的數據庫,所以整理搜集了一部分有用的SQL語句,供大家參考!
1.列出所有表結構信息
SELECT
(case when a.colorder=1 then d.name else '''' end)表名,
a.colorder 字段序號,
a.name 字段名,
(case when COLUMNPROPERTY( a.id,a.name,''IsIdentity'')=1 then ''√''else '''' end) 標識,
(case when (SELECT count(*)
FROM sysobjects
WHERE (name in
(SELECT name
FROM sysindexes
WHERE (id = a.id) AND (indid in
(SELECT indid
FROM sysindexkeys
WHERE (id =