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 |
|
Teroman
Posting Yak Master
115 Posts |
Posted - 2002-02-12 : 11:05:26
|
| Has anyone else noticed these behaving differently?I spent hours (well it felt like it) going throught a pretty mad proc looking for the mistake, and changed and IsNull for a Coalesce so i could put another argument in.That didnt work, so i took the third argument out, but being a bit lazy i left the coalesce in. To my surprise the damned thing started working, something to do with rounding i think, had a decimal(7,2) times 0.95 in the where clause. One stayed accurate, the other did notIs this kind of thing documented anywhere?Anymore of these features hiding anywhere?ThanksCol |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-02-12 : 11:18:30
|
| Can you show us the code that's acting funny? |
 |
|
|
Teroman
Posting Yak Master
115 Posts |
Posted - 2002-02-13 : 05:19:39
|
| try thisdeclare @n decimal(7,2)declare @n2 decimal(13,5)set @n2 = 12345.67891select isnull(@n * 0.95, @n2)select coalesce(@n * 0.95, @n2)gives: ------------ 12345.6789(1 row(s) affected) --------------- 12345.67891(1 row(s) affected)the isnull loses a dcimal place (sql serever v7 here)bit naughty methinks |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-02-13 : 07:09:51
|
| SQL Server 2000 sp 2:declare @n decimal(7,2)declare @n2 decimal(13,5)set @n2 = 12345.67891select isnull(NULL, @n2)select isnull(@n, @n2)select isnull(@n * 0.0, @n2)select isnull(@n * 0.00, @n2)select isnull(@n * 0.000, @n2)select isnull(@n * 0.0000, @n2)select isnull(@n * 0.00000, @n2)select isnull(@n * 0.000000, @n2)12345.6789112345.6812345.67912345.678912345.6789112345.67891012345.678910012345.67891000select coalesce(NULL, @n2)select coalesce(@n, @n2)select coalesce(@n * 0.0, @n2)select coalesce(@n * 0.00, @n2)select coalesce(@n * 0.000, @n2)select coalesce(@n * 0.0000, @n2)select coalesce(@n * 0.00000, @n2)select coalesce(@n * 0.000000, @n2)12345.6789112345.6789112345.6789112345.6789112345.6789112345.67891012345.678910012345.67891000Edited by - Arnold Fribble on 02/13/2002 07:14:35 |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-02-13 : 07:17:30
|
| Another datapoint:declare @n2 decimal(13,5)set @n2 = 12345.67891select isnull(NULL, @n2)select isnull(NULL * 0.0, @n2)select isnull(NULL * 0.00, @n2)select isnull(NULL * 0.000, @n2)select isnull(NULL * 0.0000, @n2)select isnull(NULL * 0.00000, @n2)select isnull(NULL * 0.000000, @n2)select coalesce(NULL, @n2)select coalesce(NULL * 0.0, @n2)select coalesce(NULL * 0.00, @n2)select coalesce(NULL * 0.000, @n2)select coalesce(NULL * 0.0000, @n2)select coalesce(NULL * 0.00000, @n2)select coalesce(NULL * 0.000000, @n2)12345.67891Server: Msg 8115, Level 16, State 8, Line 6Arithmetic overflow error converting numeric to data type numeric.Server: Msg 8115, Level 16, State 8, Line 7Arithmetic overflow error converting numeric to data type numeric.Server: Msg 8115, Level 16, State 8, Line 8Arithmetic overflow error converting numeric to data type numeric.Server: Msg 8115, Level 16, State 8, Line 9Arithmetic overflow error converting numeric to data type numeric.Server: Msg 8115, Level 16, State 8, Line 10Arithmetic overflow error converting numeric to data type numeric.Server: Msg 8115, Level 16, State 8, Line 11Arithmetic overflow error converting numeric to data type numeric. 12345.6789112345.6789112345.6789112345.67891012345.6789100012345.678910000012345.678910000000Edited by - Arnold Fribble on 02/13/2002 07:22:41 |
 |
|
|
Lavos
Posting Yak Master
200 Posts |
Posted - 2002-02-13 : 12:57:19
|
| IIRC, don't the arguements for ISNULL have to be of the same type or implicitly convertible, while COALESCE can take arguements of any type? If so, this "feature" might have to do with how the engine parses the parameters since it would have to start casting things to the same type for ISNULL.----------------------"O Theos mou! Echo ten labrida en te mou kephale!" |
 |
|
|
|
|
|
|
|