views:

80

answers:

2

I have a table, which contains many columns of float data type with 15 digit precision. Each column consumes 8 bytes of storage. Most of the time the data does not require this amount of precision and could be stored as a real data type. In many cases the value can be 0, in which case I could get away with storing a single byte.

My goal here is to optimize space storage requirements, which is an issue I am facing working with a SQL Express 4GB database size limit.

If byte, real and float data types are stored in a sql_variant column there is obviously some overhead involved in storing these values. What is the cost of this overhead?

I would then need to evaluate whether I would actually end up in significant space savings (or not) switching to using sql_variant column data types.

Thanks, Elan

+1  A: 

You won't save space using sql_variant and you'll simply introduce a whole level of complexity

Each column should have the correct datatype to store all possible values in this field. Do you need float across the board? Could you use tinyint? etc etc

If you're concerned about the 4GB limit then upgrade to the new Express versions (10GB) or move up an edition.

gbn
Agreed, sql_variant won't save any space. Saw the new limit on SQL Server 2008 R2. Thanks!
Elan
A: 

I found the folowing article very useful in shedding light on the cost of storage as far as sql_variant is concerned:

http://msdn.microsoft.com/en-us/library/ms178085.aspx

Elan