sql_language thread: Arithmetic overflow error converting expression to data type int
Now that is what I call help !! I like your approach to the problem.
Since I posted this message I realized that was my problem as well. I
tried to "Cast" in every direction to a float, but still I could not get
it right, a cross between logic and syntax. Of course SQL server doesn't
have the Bigint datatype, i simply put in float, and walla...problem
solved.
I really appreciate you taking the time to work me through that. Another
couple years of this, and I might just become ok at this stuff.
sincerely,
Jeff Bukovan
> Below is my Stored procedure, table, and data. When I use the stored
> procedure with this date range it runs fine:
>
> EXEC get_severity '07/14/2001 5:00:00 pm', '07/14/2001 9:00:00 pm'
>
> But when I execute it with the range of dates below which include all
data
> I get an "Arithmetic Overflow Error Converting Expression to Data Type
INT"
>
> EXEC get_severity '05/10/2001 7:00:00 pm', '07/14/2001 9:00:00 pm'
>
> So what am I missing/don't undertand, and how can I correct this problem?
>
> Thanks in advance.
>
> ~Jeff
>
>
> CREATE PROCEDURE get_severity
>
> @start datetime,
> @stop datetime AS
>
> SELECT 255.0 * SUM(ALERT_LEVEL *
> datediff(second, @start, CREATION_TIMESTAMP)) /
> (datediff(second, @start, @stop) * SUM(ALERT_LEVEL))
> FROM ACTIVITY_LOG
> WHERE CREATION_TIMESTAMP BETWEEN @start AND @stop
>
>
> CREATE TABLE [dbo].[activity_log] (
> [ACTIVITY_LOG_ID] [int] IDENTITY (0, 1) NOT NULL ,
> [ALERT_LEVEL] [int] NULL ,
> [CREATION_TIMESTAMP] [datetime] NOT NULL
> ) ON [PRIMARY]
>
> GO
>
> INSERT INTO ACTIVITY_LOG VALUES ('50', '05/10/2001 7:00:00 pm')
> INSERT INTO ACTIVITY_LOG VALUES ('50', '06/10/2001 7:30:00 pm')
> INSERT INTO ACTIVITY_LOG VALUES ('80', '07/14/2001 5:00:00 pm')
> INSERT INTO ACTIVITY_LOG VALUES ('80', '07/14/2001 6:00:00 pm')
> INSERT INTO ACTIVITY_LOG VALUES ('80', '07/14/2001 7:00:00 pm')
> INSERT INTO ACTIVITY_LOG VALUES ('250', '07/14/2001 8:00:00 pm')
>
>
>
>
>