How to determine table data sizes via T-SQL 0

I needed a quick and dirty way to find out how much data tables were consuming in a SQL Server database. Ripping off what sp_spaceused does, I came up with this:

[sql] SELECT t.name, LTRIM (STR ( SUM ( CASE WHEN (index_id < 2) THEN (in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count) ELSE lob_used_page_count + row_overflow_used_page_count END ) * 8, 15, 0) + ‘ KB’) AS DataSize FROM sys.dm_db_partition_stats s INNER JOIN sys.tables t ON t.object_id = s.object_id GROUP BY t.name [/sql]

Unit Testing in SQL Server – Overview 1

Ok, so here’s the first in a series of a home grown implementation of Unit Testing SQL server code.

I’m not talking about using Visual Studio Team Edition for Professionals, like Jeff recommends… but I’ll try to provide a general approach to testing your SQL code, particularly stored procedures (sprocs). Read more »

Venn Diagrams explain SQL Joins Perfectly 0

In a series of posts on both Coding Horror and the linked Me Talking Out Loud, comments have arisen that suggest Venn diagrams are insufficient to properly represent SQL Joins.

I totally disagree, Venn diagrams fit perfectly. The biggest problem is Read more »