dbTalk Databases Forums  

Re: Error converting varchar value '8.80' to a value of data type int

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Re: Error converting varchar value '8.80' to a value of data type int in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Error converting varchar value '8.80' to a value of data type int - 07-21-2004 , 09:08 AM






Please see my reply to your exact same post under a different subject

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Kermit Baker" <KermitBaker (AT) discussions (DOT) microsoft.com> wrote

Quote:
While running a SQL query with the following line:
sum( case when SgnSigField = 'PR4650' then SgnValue else 0 end) as
EuAmount1,
I get the following error:
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '8.80' to a column of data type
int.

I have tried to cast the field: with NO success.

Any advice is greatly appreciated

Thank you,
Kermit Baker II




Reply With Quote
  #2  
Old   
DHatheway
 
Posts: n/a

Default Re: Error converting varchar value '8.80' to a value of data type int - 07-21-2004 , 10:14 AM






"Kermit Baker" <KermitBaker (AT) discussions (DOT) microsoft.com> wrote

Quote:
While running a SQL query with the following line:
sum( case when SgnSigField = 'PR4650' then SgnValue else 0 end) as
EuAmount1,
I get the following error:
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '8.80' to a column of data type
int.

I have tried to cast the field: with NO success.

Any advice is greatly appreciated

Thank you,
Kermit Baker II

This works in SQL Server 2000:

create table x
(x1 char(1),
x2 varchar(10))
go

insert x values ('a','80.5')
insert x values ('b','75.0')
insert x values ('a','80.5')
go

select sum(case when x1 = 'a' then cast(x2 as real) else 0.0 end)
from x
go

drop table x
go

The result is 161.0. Maybe using the 0 is implicitly an INT and, when mixed
with real or decimal(n,m) where m <> 0, causes additional conversion
problems?

I'd have used your column names and data types from your DDL in my example
but you didn't supply any DDL.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.