Saturday, November 30, 2013

Integer Ranges in SQL Server 2012

I was looking at the numeric data types in SQL Server 2012. I wanted to learn the ranges of the integer data types, but didn't want to memorize them. Noticing that each larger data type is twice the size of the smaller one was the key:

 tinyint  1 byte 
 smallint  2 bytes 
 int  4 bytes 
 bigint  8 bytes 

Since a byte is 8 bits, an integer data type can hold 2(8*bytes).

Let's run the numbers:

A tinyint can hold a value as large as 28. 28 is 256, and a tinyint doesn't use negative numbers,so it can hold values from 0 to 255. 

A smallint is 2 bytes, or 16 bits. 216=64K, so a smallint can range from a minimum of -32K to a maximum of 32K-1. The calculation of the exact values is left as an exercise for the reader.

An int is 4 bytes, so we're talking about 232. I know this one by remembering a 32-bit CPU can address 4GB of RAM, which makes the range not 0-4G, but -2G to 2G-1.

Finally, a bigint is 8 bytes. 232 is...a really big range. According to Books Online, the minimum value is -9,223,372,036,854,775,807. The bigint tops out at 9,223,372,036,854,775,808.

As always, refer to Books Online for more detail.

Sunday, January 20, 2013

Exam 70-432: Week 1

Week 1 is done. Here's what I accomplished:
The hardest part is going to be posting something substantial in an online forum each week. I don't have enough technical knowledge to contribute anything meaningful -- at least not yet.

On to Week 2.

Tuesday, January 15, 2013

Exam 70-432: Week 1 - QotD

This week's Question of the Day from SQLServerCentral.com is about ghost process cleanup.

I knew nothing about ghost records or the ghost process (in fact, I had never heard of them), so Bing to the rescue.

I found an article where Paul Randal that explains the ghost record cleanup process. Using the information from the article, I came up with the correct answer of '2'.


Sunday, January 13, 2013

Exam 70-432: If At First You Don't Succeed...

You may know that I designed a self-directed class for passing exam 70-432. Well so far, it's been a flop. I didn't allow myself enough time to cover each topic, and I spent way too much time producing output from the lab exercises.

But I'm not giving up. To quote Curly: "If at first you don't succeed, keep on sucking till you do succeed."1


So, here's 70-432, version 3.0. This time, we'll focus on explaining concepts, instead of turning in homework. Lab exercises and practice tests are still part of the curriculum, but they're no longer the main emphasis.

Take a look at the syllabus, and let me know what you think. Check back for updates, and maybe take the class yourself.


1. http://quotationsbook.com/quote/29987/