martes, 1 de diciembre de 2015

SQL - Tablas con registros en la Base de Datos

--USE BASE_DE_DATOS
SET NOCOUNT ON DBCC UPDATEUSAGE(0) -- DB size.
--EXEC sp_spaceused-- Table row counts and sizes.
CREATE TABLE #t (     [name] NVARCHAR(128),  
 [rows] CHAR(11),  
 reserved VARCHAR(18),    
 data VARCHAR(18),    
 index_size VARCHAR(18),  
 unused VARCHAR(18))
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?'''
SELECT 'TABLAS CON MAS DE UN REGISTRO',* FROM   #t WHERE rows > 0   -- # of rows.
SELECT COUNT(*) AS tablas_con_datos FROM   #t WHERE rows > 0
DROP TABLE #t

No hay comentarios:

Publicar un comentario