473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error converting data type varchar to numeric

7
Hi

I wonder if anyone can help - I think the answer is simple but it's been a really long day and I need to get this done!!

My select statement goes like this...


SELECT
client,
apar_id,
ext_inv_ref,
case when amount ='' then '0' else amount end,
currency,
convert (varchar,payment_date,112),
voucher_no,
convert (varchar,voucher_date,121)

from acuhistr
where client = 'SD'
and account = '9299'

I get the error: Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.

I get why it's saying it, but I cannot work out how to convert the 'blank' into numeric or the numeric into varchar! Any ideas muchly appreciated
Oct 1 '09 #1
3 24126
ck9663
2,878 Expert 2GB
What's the data type of your amount column? What do you mean by this line:

Expand|Select|Wrap|Line Numbers
  1.  
  2. case when amount ='' then '0' else amount end
  3.  
  4.  

--- CK
Oct 1 '09 #2
lornab
7
Hiya

The amount column is a numeric I believe. What I am saying in the case statement is if the amount is blank then populate the result with 0 or 0.00 or else put the result amount in.

I have just rerun the query, and I have actually got .000 in my result! I think my problem actually lies in getting it to print the 0.00 or.000 in my ARW that I am putting the sql into. This is my result so far:
SD 29963 888 299.000 DKK 20091001 3000000 2009-10-01 00:00:00.000
SD 29963 444 .000 DKK 20091001 3000002 2009-10-01 00:00:00.000

Thanks anyway, but I am going to have to look at my report that I am using the sql in rather than the sql itself....I think it's going to be another long day :)
Oct 2 '09 #3
ck9663
2,878 Expert 2GB
By default, numeric data stores NULL, not blank. If what you're trying to do is to return 0 or 0.00 instead of NULL, use the ISNULL() function instead.

Happy Coding!!!

--- CK
Oct 2 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Amir | last post by:
Hi all, I have a table called PTRANS with few columns (see create script below). I have created a view on top that this table VwTransaction (See below) I can now run this query without a...
1
by: Jay | last post by:
I hope this is the correct place to post this. I'm using a stored procedure to simply look up and return a value from a database. The db key is an integer, everything else is varchar. The stored...
4
by: Viktor Popov | last post by:
Hi, I'm trying to execute stored procedure and I collect its parameters from WebForm. There is an error: Error converting data type varchar to int. What could be the problem? Here it is the...
2
by: Leon Shaw | last post by:
Please help me understand this Error??? Server Error in '/solo' Application. ---------------------------------------------------------------------------- ---- Object must implement...
1
by: luna | last post by:
got so far then it broke and i cant get it working again - it was updating fine but not inserting and now im getting a "Error converting data type varchar to numeric" which i didnt have before.......
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
0
by: rajmgopal | last post by:
Hello Everyone I am getting the following error when i try to insert a record into Sql Server 2005 from my VB 2005 application. sqlEx = {"Error converting data type numeric to numeric."} I...
3
by: othellomy | last post by:
select convert(float,'1.2334e+006') 1233400.0 select convert(decimal(20,2),'1.2334e+006') Server: Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric. can I set...
0
by: jjtechy | last post by:
The data like 0.06234 that is imported from another server is getting changed as 6.234....E-2 in my local.it is looking as 0.06234 in that server.The datatype of that column is varchar(50) in both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.