Technical Article

Numero de Registros y espacio usado en disco

,

Copie y pegue el código, en la base de datos que va a analizar

luego ejecútelo

 

/* script creado por Augusto Alfonso */

declare @name sysname
declare @SQL nvarchar(1000)
declare @id varchar(100) 
create table #2 (
    ID varchar(100),
    NAME varchar(50)
)

create table #3 (
    name_table varchar(100), -- Name of table
    Num_Rows INTEGER, -- Number of rows 
    Size INTEGER, -- Size in KB
)

INSERT INTO #2 SELECT object_id, name FROM sys.objects WHERE type = 'U' order by name

declare C1 CURSOR FOR
    SELECT ID FROM #2
BEGIN
    OPEN C1
    FETCH NEXT FROM C1 INTO @id
    WHILE (@@FETCH_STATUS <> -1)
     BEGIN
            SELECT @SQL = 'insert into #3
                            select
                            OBJECT_NAME(' + @id + '),
                         SUM ( 
                         CASE 
                            WHEN (index_id < 2) THEN row_count 
                            ELSE 0 
                         END 
                         ) ,
                        (SUM (reserved_page_count) * 8)
                         FROM sys.dm_db_partition_stats 
                         WHERE object_id = ' + @id;
            EXECUTE (@SQL)
            FETCH NEXT FROM C1 INTO @id
     END
    CLOSE C1
    DEALLOCATE C1

END
Select * from #3 Order by Size

Rate

3 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

3 (3)

You rated this post out of 5. Change rating