Fast record count in SQL Server using sp_spaceused
December 7th, 2011 in Blog, SQL ServerJust a quick tidbit today, but a very useful one. Ever need to do SELECT Count(*) on a very large table? It can take ages. Instead, use sp_spaceused EXEC sp_spaceused 'MyTable' It returns you a useful result set like name rows reserved data index_size unused MyTable 19690290 13637488 KB 3001688 KB 9986416 KB 649384 KB Not only does it also give you extra useful information about the table, but it comes back virtually instantly. Columns:…
» Read more