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 |
natas
Yak Posting Veteran
51 Posts |
Posted - 2005-06-14 : 04:35:19
|
HelloDECLARE @littlenumber tinyintDECLARE @biggernumer smallintSET @littlenumber=20SET @biggernumber=30IF(@littlenumber>@biggernumber)BEGINSELECT 'the littlenumber is bigger'ENDWhat i would like to know if it mather what type of "integer" it is.If it makes a difference?. Does it have to be the same datatype when you do comparison?. |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-14 : 04:46:19
|
not really...Go with the flow & have fun! Else fight the flow |
|
|
natas
Yak Posting Veteran
51 Posts |
Posted - 2005-06-14 : 12:20:27
|
So it doesnt mather at all if i compare tinyint and smallints?, there can not be any errors? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-14 : 12:40:51
|
what error do you expect?? it's just number comparison:DECLARE @littlenumber tinyintDECLARE @biggernumber smallintSET @littlenumber = 25--SET @littlenumber = 300 -- this returns an overflow error SET @biggernumber = 500IF(@littlenumber > @biggernumber) SELECT 'the littlenumber is bigger'IF(@littlenumber < @biggernumber) SELECT 'the littlenumber is lower'IF(@littlenumber = @biggernumber) SELECT 'numbers equal'IF(@littlenumber <> @biggernumber) SELECT 'numbers not equal' Go with the flow & have fun! Else fight the flow |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-06-14 : 13:10:58
|
The difference between the 2 datatypes is one of storage size and possible value range.tinyint is 1 byte with possible values of 0 to 255smallint is 2 bytes with possible values of -32768 to 32767sql server will handle implicit conversions (when necessary) for performing comparisons.Be One with the OptimizerTG |
|
|
|
|
|