How To Get Table Row Counts Quickly And Painlessly
Use sysindexes\DMVs insead of select count(*) to retreive table row counts
2011-01-28 (first published: 2009-09-02)
55,574 reads
simpledba,
2014-04-24 (first published: 2014-04-05)
---Objetivo:Contar registros de tu base de datos ---Fecha:03/04/2014 ---Autor:Andrés Noé Michaca Trujillo set nocount on create table #tablas ( nombre varchar(80), registros INT ) declare @table varchar(80), @CadenaSQL varchar(200) declare tablecurs cursor for select '['+ltrim(rtrim(sq.name))+'].['+ltrim(rtrim(obj.name))+']' from sys.objects obj inner join sys.schemas sq on obj.schema_id =sq.schema_id where obj.type = 'U' and obj.name <>'sysdiagrams' order by sq.name,obj.name open tablecurs fetch tablecurs into @table WHILE @@FETCH_STATUS = 0 Begin Select @CadenaSQL = 'select '''+ @table +''', count(*) from '+ @table insert into #tablas exec(@CadenaSQL) fetch tablecurs into @table end deallocate tablecurs go select * from #tablas GO drop table #tablas GO
Use sysindexes\DMVs insead of select count(*) to retreive table row counts
2011-01-28 (first published: 2009-09-02)
55,574 reads
Dattatrey Sindol explains the different ways in which you can get the row counts from all the tables in a SQL Server database.
2017-06-22
5,549 reads
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.
2003-01-13
18,069 reads
Binary data can be stored as integers in a table. This article explains how to query an integer field to return the bits represented by the integer.
2002-06-28
4,567 reads
This article demonstrates how to retrieve a single record from SQL Server by using the IRow interface with a singleton SELECT. The main purpose for this technique is to avoid the overhead of creating a recordset when you are fetching a single record. Because no recordset is actually created, only one read-only ADODB.Record is returned. This is true even if the specified SELECT results in multiple records being returned if a normal ADODB.Recordset is used.