Solved

Error Converting Data Type Varchar To Numeric When Updating Field

Posted on 2009-07-14
3
242 Views
Last Modified: 2012-05-07
Hey guys, I imported pricing into my table and some were a NULL (empty) value and when I try to update them to '0.0000' I get the following 'Error converting data type varchar to numeric.'

Select * from MyTable
Where Price = ''
also returns the error 'Error converting data type varchar to numeric.'

Is there any way I can update the db, or will I need to change my master import file not to contain null values?

Cheers

0
Comment
Question by:Girac
  • 2
3 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24854149
Select * from MyTable
Where Price is null

OR

Select * from MyTable
Where ISNUMERIC(Price) = 0
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24854203
update urTable
SET NumericColumn = 0
WHERE NumericCOlumn is null or ISNUMERIC(NumericColumn) =  0
0
 

Author Comment

by:Girac
ID: 24854280
Once I seen the 'Where ISNUMERIC(Price) = 0 ' I was able to update.

Cheers,
G
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Powershell v3 - SQLCMD 3 27
SQL Quer 4 22
sql 2016 data tools breakdown.. 1 15
MS SQL + group by time 4 15
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question