SQL Server 2000, how to automate import data from excel

Posted by Stan on Stack Overflow See other posts from Stack Overflow or by Stan
Published on 2010-05-13T23:13:02Z Indexed on 2010/05/13 23:24 UTC
Read the original article Hit count: 187

Filed under:

Say the source data comes in excel format, below is how I import the data.

  1. Converting to csv format via MS Excel
  2. Roughly find bad rows/columns by inspecting
  3. backup the table that needs to be updated in SQL Query Analyzer
  4. truncate the table (may need to drop foreign key constraint as well)
  5. import data from the revised csv file in SQL Server Enterprise Manager
  6. If there's an error like duplicate columns, I need to check the original csv and remove them

I was wondering how to make this procedure more effecient in every step? I have some idea but not complete. For step 2&6, using scripts that can check automatically and print out all error row/column data. So it's easier to remove all errors once. For step 3&5, is there any way to automatically update the table without manually go through the importing steps?

Could the community advise, please? Thanks.

© Stack Overflow or respective owner

Related posts about sql-server-2000