이 코드는 codeproject에서 발견되었습니다. 아주 편리합니다.
-- Author,,Md. Marufuzzaman
SELECT SYS_OBJ.NAME AS "TABLE NAME"
, SYS_INDX.ROWCNT AS "ROW COUNT"
FROM SYSOBJECTS SYS_OBJ, SYSINDEXES SYS_INDX
WHERE SYS_INDX.ID = SYS_OBJ.ID
AND INDID IN(0,1) --This specifies 'user' databases only
AND XTYPE = 'U' --This omits the diagrams table of the database
--You may find other system tables will need to be ommitted,
AND SYS_OBJ.NAME <> 'SYSDIAGRAMS'
ORDER BY SYS_INDX.rowcnt DESC --I found it more useful to display
--The following line adds up all the rowcount results and places
--the final result into a separate column [below the first resulting table]
COMPUTE SUM(SYS_INDX.ROWCNT)
GO
시도하는 SQL을 게시 할 수 있습니까? 그것은 아마도 Count가 아니지만 문제를 일으키는 조인 또는 인덱스 일 가능성이 큽니다. –
당신의 조인을 확인하십시오. 항상 잘 사용했습니다. 카운트 (*)의 대안은 SUM입니다 ([yourcondition] THEN 1 ELSE 0 END).하지만 카운트가 더 빨라야합니다. – RandomUs1r