-- 테이블 용량 조회
DECLARE @SIZE INT -- 관리대상 테이블 크기(KB)
DECLARE @LOW BIGINT
SELECT @LOW = LOW FROM MASTER.DBO.SPT_VALUES
WHERE NUMBER = 1 AND TYPE = 'E'
SELECT TMP.CRDATE AS DATES
,OBJECT_NAME(TMP.ID) AS NAME
,CONVERT(CHAR(11),SUM(ROWS)) AS ROWS
,LTRIM(STR(SUM(TMP.RESERVED) * @LOW / 1024.,15,0) + ' ' + 'KB') AS RESERVED
,LTRIM(STR(SUM(TMP.DATA) * @LOW / 1024.,15,0) + ' ' + 'KB') AS DATA
,LTRIM(STR((SUM(TMP.USED) - SUM(TMP.DATA)) * @LOW / 1024.,15,0) + ' ' + 'KB') AS INDEX_SIZE
,LTRIM(STR((SUM(TMP.RESERVED) - SUM(TMP.USED)) * @LOW / 1024.,15,0) + ' ' + 'KB') AS UNUSED
FROM (
SELECT OBJ.ID AS ID, SUM(IND.ROWS) AS ROWS, SUM(IND.RESERVED) AS RESERVED, SUM(DPAGES) AS DATA,
ISNULL(SUM(USED), 0) AS USED, MAX(OBJ.CRDATE) AS CRDATE
FROM SYSINDEXES IND JOIN SYSOBJECTS OBJ ON IND.ID = OBJ.ID
WHERE OBJ.XTYPE='U' AND IND.INDID < 2
GROUP BY OBJ.ID
UNION
SELECT OBJ.ID AS ID, 0 AS ROWS, SUM(IND.RESERVED) AS RESERVED, ISNULL(SUM(USED), 0) AS DATA,
ISNULL(SUM(USED), 0) AS USED, MAX(OBJ.CRDATE) AS CRDATE
FROM SYSINDEXES IND JOIN SYSOBJECTS OBJ ON IND.ID = OBJ.ID
WHERE OBJ.XTYPE='U' AND IND.INDID = 255
GROUP BY OBJ.ID ) TMP
GROUP BY TMP.ID, TMP.CRDATE
-- 조건추가
--HAVING SUM(TMP.DATA) * @LOW / 1024. > 200 * 1024
ORDER BY SUM(TMP.DATA) DESC, SUM(TMP.USED) DESC
PROCEDURE (0) | 2024.12.11 |
---|---|
split (0) | 2024.12.06 |
데이타 한글 포함여부 (0) | 2023.03.17 |
SQL Express 비밀번호 변경 (0) | 2021.06.14 |
SQL Server 어셈블리 등록 (0) | 2021.06.14 |