2006/08/25

[SQLServer2000]查出資料庫各表格的資訊

SELECT
 sysusers.name + N'.' + sysobjects.name as ObjectName,
 sysindexes.name as IndexName,
 sysindexes.rows, --資料列
 case indid when 1 then 1 else 0 end as IsClusteredIndex,
 sysindexes.indid, --索引的識別碼
 sysobjects.name, --物件名稱
 sysusers.name --使用者名稱或群組名稱在資料庫中是唯一的
FROM
 sysusers, sysobjects, sysindexes
WHERE
 sysusers.uid = sysobjects.uid
 and sysindexes.id = sysobjects.id
 and sysobjects.name not like '#%'
 and OBJECTPROPERTY(sysobjects.id, N'IsMSShipped') <> 1
 and OBJECTPROPERTY(sysobjects.id, N'IsSystemTable') = 0
ORDER BY
 ObjectName, IsClusteredIndex DESC,
 indexproperty(sysindexes.id, sysindexes.name, N'IsStatistics'),
 IndexName

沒有留言: