Import from csv file

  • Dear All

    Everyday I recieve csv file from 20 different location file name is like that yyyymmddLocationID.csv this file has 5 columns. First column contains location code 2 nd column contains date (numeric), third column contains ProductID and last two column contain numeric value. Now everyday I need to import every csv file into our SQL server. I created a table name ztblRDBNCDSPRINT and where primary is locationcode,date and ProductID. So no duplicate row will not insert like so same date same location same productid will not be insert.

    Now inform me how can I import into SQL.

  • Use DTS to import the csv file. Look in Books OnLine for tutorials on how to use this tool from Enterprise Manager.

  • I would prefer to go the BCP way.

  • You can also use BULK INSERT (Which is rapped by BCP) from within script of a proc.

    See BOL for help on that. Works well and fast.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Hi

    When i read this topic - i remember i encountered a problem - a year back i was importing a CSV file (a very large file) into SQL Server - but the operation used to timeout even when i used bulk insert and the data never got inserted. Can anybody tell me where i went wrong.

  • What actually timed out? ASP or SQL?

    If it was ASP script timeout then the reason was because ASP was waiting for to long (15 minutes default) before getting a respone.

    Increasing the script time out delay would have solved the problem.

    Did the import complete if you ran the script throught QA?

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Thanks, The Time was from SQL Server i tried BULK INSERT in Query Analyser. i dont know if this will help but the CSV file contained about 120,000 records.

    Thanks again

Viewing 7 posts - 1 through 6 (of 6 total)

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