Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2015

    Unanswered: Newbie Data Import Question

    I am new to SQL Server. I am using Version 2013.

    I want to load data from a s/sheet into a new table. Columns are defined in my Excel 2013 sheet, just want to import the data into a table by mapping fields.
    Can someone give me a T-SQL script or point me in the right direction?

    New table, different from Step1.
    I have tonnes of Excel files. I want to interate through each line by data loading, however if there is a duplicate based on 3 or 4 key fields, i.e. firstname, lastname, telephoneno, postcode, I want the system to omit the record but instead put them into an Exception table.

    I hope you can help me?

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    You haven't provided enough details for a specific answer, but I can contribute some general ideas.

    For your first question (imported data from a spreadsheet into SQL Server), use SSIS if the columns are not perfectly regular. A linked server is conceptually simpler so it might seem like a good idea at first, but it breaks down and gets quite complicated if there is any irregular data in your spreadsheet.

    For your second question, where you want to import data and do special handling for duplicate data, the "secret sauce" is that you need to create three tables. One table is for "production" use, or in other words the finished product. One table is purely used for staging data, a place to plant the incoming data in its raw form. The third table is to store the exceptions.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Oct 2014
    Provided Answers: 7
    Here is what I do

    Find the database name in the object explorer
    Right click on the database > Task > Import Data
    Change DataSource to Excel, CSV, TXT etc
    Browser to the file

    From there you should be able to walk through the rest for import.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts