How Many Rows in a Table?

30 באפריל 2009

Have you ever wondered how many rows your SQL Server database tables contains? A few times now I've wanted to grab a list of table names with the row count for each table. In a post about a few undocumented Stored Procedures I came across this neat script.EXEC sp_MSforeachtable 'SELECT ''?'', Count(*) as NumberOfRows FROM ?' It uses an undocumented stored procedure that iterates over all user tables in the database. The only issue I had with it, was that the output was really tedious to read. I wanted a simple tabular display showing me a list of tables with their name and number...
no comments

Solving an Expensive Database Lookup

26 באפריל 2009

We had an interesting problem the other day. In our database (SQL Server 2008) we have a few tables with possibly many millions of records. We send some of the data from these and related tables to a third party service for processing and get status reports back. The problem was that the reports that we get back cannot easily be correlated back to the original records in our database. Let’s say we have a person table and an address table with a 1:m relationship between person and address. The tables could look something like: Together with the person and...
no comments