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.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Msg 8115 when selecting with count(*)

Author  Topic 

sebbie
Starting Member

1 Post

Posted - 2008-03-19 : 07:16:07
I've strange problem with select query. Look at count(*) condition in queries:

select fullpostcode,count(*) from pst_Postcodes
group by fullpostcode having count(*)>1

causes

Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.

but

select fullpostcode,count(*) from pst_Postcodes
group by fullpostcode having count(*)>=2

(0 row(s) affected)

Table is simple:

CREATE TABLE [dbo].[pst_Postcodes](
[OuterCode] [char](4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[InnerCode] [char](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Type] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Easting] [int] NOT NULL,
[Northing] [int] NOT NULL,
[Latitude] [decimal](18, 5) NULL,
[Longitude] [decimal](18, 5) NULL,
[DpCount] [int] NULL,
[ID] [int] IDENTITY(1,1) NOT NULL,
[FullPostCode] [char](8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_pst_Postcodes] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

I'm using SQL2005 Enterprise Edition (9.0.3042) on Windows 2003 (NT5.2 3790). Any ideas why's that?

--
sebbie
   

- Advertisement -