Home > Ask the SQL Server Experts > Michael Hotek Questions & Answers > Error converting varchar to numeric
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Error converting varchar to numeric

Michael Hotek EXPERT RESPONSE FROM: Michael Hotek

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 21 January 2004
I am using DTS to take a text file and create a one column table (varchar). From here I am parsing (using substring commands) the one column table into several tables based on a criteria - and that's working fine. Until I try to create a numeric column in any of the tables. I'm receiving "Error converting varchar to numeric". Is there a workaround for this?

>
EXPERT RESPONSE

What is the structure of the table to start with and what is the DDL you are issuing to alter the table?

Editor's note: In resonse to Michael's request for more information, the user replied to say that she had resolved the issue. Here is what she said:

I have resolved the issue, I will try to explain so others may benefit...

The text file had fields created in COBOL as 9(7).9(4)-. The decimal and sign were hard coded. Every time I tried to create the table with a numeric column [numeric](13,4) null, and run the following code I got an error.

insert into Table_Name
 select 
 substring(onecolumntable,1,13) as cost, 

I found out that SQL Server 2000 does not like the hard coded sign on the right of the expression so - this is what I did...

insert into Table_Name
 select  
 substring(onecolumntable,13,1) + substring(onecolumntable,1,12) as
Cost


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Michael Hotek
Applying LDF file to MDF without turning it to .BAK first?
Procedure for finding last modified info?
Migrating poorly designed database to new, normalized one
Displaying decimal places in SQL Server 2000
Creating a DTS package
Extracting data without strings converted to strange characters
Money data type conversion issue using DTS
Any way to alias a call to functions?
Repairing corrupt MDF files
In-place versus side-by-side upgrade

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2005 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts