June 17, 2013 at 10:23 am
I have a select statment,but get an error:
Arithmetic overflow error converting float to data type numeric.
SELECT CAST(SUM(C.PeriodsAbsent) AS numeric(4,1)) PeriodsAbsent
from calendar c
I see the distinct PeriodsAbsent values are 0, 1, 2, 3, ..to 14.
How can i fix this?
thanks
June 17, 2013 at 10:37 am
June 17, 2013 at 12:24 pm
Thanks, I do see there is a number 1011.
Shall I change it to (5,1)
Thanks
June 17, 2013 at 12:37 pm
sqlfriends (6/17/2013)
Thanks, I do see there is a number 1011.Shall I change it to (5,1)
Thanks
Just my 2¢ but why keep it so small? Since it is holding aggregate data let it have some room to grow if it needs it. Numeric(7,1) or even (9,1). The actual storage space is 5 bytes for any numeric value 9 digits or less.
http://msdn.microsoft.com/en-us/library/ms187746.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 17, 2013 at 12:39 pm
Thanks, it is good to know.
I am changing some one else code, so need to be careful
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply