SQL Server emergency? Email pinal@sqlauthority.com with URGENT in the subject line.

Distance Between Two Points on the Earth With the geography Type

The distance between two points on the earth takes one method call once you store the points as a geography value. This post builds a small table of five US cities, turns latitude and longitude into points, and measures with STDistance in meters, kilometers and miles. It also compares the answer with a flat map formula and a sphere formula, and shows the error for swapped arguments.

Continue Reading

Data Row Space Usage: Estimate Row Size Before the Table Grows

Data row space usage is the number of bytes one row takes, and every table size estimate starts there. This post adds up the five parts of a row for a small table of rooms and checks the result against what SQL Server reports. It also shows that NULL does not shrink a fixed-length column, and turns 100,000 rows a day into pages and megabytes.

Continue Reading