DEV Community

Singh Sachina
Singh Sachina

Posted on

Table with the most records in the database. | Database me sabse zyada records wali table

SELECT TOP 1
s.name AS SchemaName,
t.name AS TableName,
SUM(p.rows) AS TotalRows
FROM sys.tables t
JOIN sys.schemas s ON t.schema_id = s.schema_id
JOIN sys.partitions p ON t.object_id = p.object_id
WHERE p.index_id IN (0, 1)
GROUP BY s.name, t.name
ORDER BY TotalRows DESC;

Top comments (0)