meverest
asked on
int overflow
Hi folks,
i have a proxy server logging to MMSSQL table. i want to summarise the traffic each day to total per IP address. i use this stored proc:
CREATE PROCEDURE update_TrafficLog @day int = 0
AS
insert into TrafficLog
select clientIP, convert(smalldatetime,conv ert(char, logtime,101),101), sum(bytessent) as bytesDelivered, 'proxy', 'proxy', newid()
from mspSrvLog
where logtime < convert(smalldatetime,conv ert(char, dateadd(d, -@day, getdate()),101),101) and logtime >= convert(smalldatetime,conv ert(char, dateadd(d, -1-@day, getdate()),101),101)
group by clientIP, convert(smalldatetime,conv ert(char, logtime,101),101)
delete mspsrvlog where logtime < convert(smalldatetime,conv ert(char, dateadd(d, -1-@day, getdate()),101),101)
GO
the column 'bytessent' is type int
the destimation column for sum(bytessent) is type bigint.
but sometimes this happens when i run the storedproc above:
Server: Msg 8115, Level 16, State 2, Procedure update_TrafficLog, Line 5
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
(0 row(s) affected)
- i assume that this is caused by the statement sum(bytessent) evaluating to a value greater than max INT - which being 2,147,483,647 is only 2.15GB, and not unlikely that this much data would be delivered to one address in a given day....
so how can i evaluate the sum(bytessent) as bigint?
cheers!
i have a proxy server logging to MMSSQL table. i want to summarise the traffic each day to total per IP address. i use this stored proc:
CREATE PROCEDURE update_TrafficLog @day int = 0
AS
insert into TrafficLog
select clientIP, convert(smalldatetime,conv
from mspSrvLog
where logtime < convert(smalldatetime,conv
group by clientIP, convert(smalldatetime,conv
delete mspsrvlog where logtime < convert(smalldatetime,conv
GO
the column 'bytessent' is type int
the destimation column for sum(bytessent) is type bigint.
but sometimes this happens when i run the storedproc above:
Server: Msg 8115, Level 16, State 2, Procedure update_TrafficLog, Line 5
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
(0 row(s) affected)
- i assume that this is caused by the statement sum(bytessent) evaluating to a value greater than max INT - which being 2,147,483,647 is only 2.15GB, and not unlikely that this much data would be delivered to one address in a given day....
so how can i evaluate the sum(bytessent) as bigint?
cheers!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
regards.