[RESOLVED] [SQL 2000] Rounding Problem
Hello,
I have the following line in my stored procedure :
Code:
SET @ErrMSG = 'Employee : ' + STR(@Employee) + ' Only Has ' + STR(@AllowanceLeft) + ' days left to take.'
When I debug through to the @AllowanceLeft part, it shows as 2.5000
However, this message displays it as 3.
How do I stop it rounding up please ?
Re: [SQL 2000] Rounding Problem
That's because you aren't specifying enough parameters to the Str function, so it applies the default behaviour, which is rounding.
See the help for it (online version here) for more details.
Re: [SQL 2000] Rounding Problem
Thanks Si, that's excellent.
Apologies for not looking there first and wasting your time - I have no excuse.
Re: [RESOLVED] [SQL 2000] Rounding Problem
I am curious why you are using STR() instead of CAST().
CAST() is much more data-aware in regard to the source datatype and the chosen destination datatype.
CONVERT() even has more specific functionality in regard to datatype conversion.
(I didn't even know that STR() was a SQL function ;) )