Struggling with a CSV file

  • I have a CSV file that I need to import into a table. The records looks like the following:

    110,"LIBFIN",9002965,60,09/26/08,"T 43091 Jim Ugly",1,06/08/09 08:51 AM

    110,"LIBFIN",9008263,1315,09/30/08,"T 200751 The devil's arithmetic",1,06/08/09 08:51 AM

    110,"LIBFIN",9013247,170,10/01/08,"T 11129 Just Ella",1,06/08/09 08:51 AM

    The 4th field over, the 60, the 1315, and the 170 need to go into a Money field. The 60 is really $0.60, the 1315 is really $13.15, and the 170 is really $1.70. I'm struggling trying to do it during the SELECT CASE method, but that fails. I've not yet tried to do it with an INSERT.

    Any suggestions?

    Thanks, Ted.

  • It seems that what you're being given to import is the value without a decimal point. Since you're talking about using a select case, how does dividing that number by 100.0 work (note the 100.0, not 100 - use the first to get real numbers back (with decimals); use the second to get the truncated integer back)?

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Hi WayneS,

    That worked. It is always something simple that we make it out to be hard. 🙂

    Ted.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply