Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2003-06-17 : 17:54:30
|
| This is a design question.Let say I have an INT field in a table called PagesToPrint. Sometimes, users will want a finite number of pages, other times they want "all". There's no way for me to calculate how many pages "all" is, so I was thinking of using NULL to indicate "all"That would give me values like:05100NULLDoes using Null in this way make sense? Is it a valid technique? Is there a better way? I do this sort of thing quite often, and I always feel like it's a "hack" or something.Any advice would be greatly appreciated!Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-06-17 : 19:00:24
|
It's not a hack IMHO, but you can still use some other replacement value if you want. Something like 1,000,000 would work too, if anyone actually needs to print more than 1 million pages they messed up anyway. That way you don't have to add any particular logic to work around the null. |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2003-06-17 : 19:14:55
|
| Michael,Because I really dislike NULLs, I would go with a value as Rob suggested. I would have thought -1 would be a good candidate...And another thing why a INT? Surely a SMALLINT would do nicely..Whatever you choose.. document it!DavidM"SQL-3 is an abomination.." |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-06-17 : 19:18:58
|
quote: I would have thought -1 would be a good candidate...
Yeah, I thought of that too I guess if two people come up with the same idea independently, then it's probably a good idea........or they're psychic somehow. |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2003-06-17 : 19:46:08
|
| You never know when you have that 2 billion page report!!!Actually, this was just an example of what I'm trying to do. I think I like -1 and a SmallInt field.Thanks all!!Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2003-06-17 : 19:50:55
|
| Rob,I used -1 so that it would be in the range of the smallint! And quite frankly I see users "mess up" all the time and I can imagine the toner bill after a few of those stuff up ;-)DavidM"SQL-3 is an abomination.." |
 |
|
|
|
|
|
|
|