How to import only new rows to MS SQL from Excel file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mushtaqawais
    New Member
    • Jul 2010
    • 3

    How to import only new rows to MS SQL from Excel file

    Hi All,

    I am using MS SQL 2008 import/export utility to import an excel file that is regularly updated.
    How can I use import /export utility every time to append only new rows to SQL table.
    I an new to SQL and do not know SSIS as well, more familiar with import/export only.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    It would be better if you IMPORT the entire excel file into a temp table, then you can compare it with your master table to see which records are new ones. You will need a primary key to identify which records are new or not.

    Once identified, you can do whatever you want with the new record. Once your session is over, your temp table will be dropped or you may drop it explicitly.

    Good Luck!!!

    ~~ CK

    Comment

    • mushtaqawais
      New Member
      • Jul 2010
      • 3

      #3
      Originally posted by mushtaqawais
      Hi All,

      I am using MS SQL 2008 import/export utility to import an excel file that is regularly updated.
      How can I use import /export utility every time to append only new rows to SQL table.
      I an new to SQL and do not know SSIS as well, more familiar with import/export only.
      Thanks Ck9663,

      Is there any way to link SQL server with excel file, so that it automatically import & process data.

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Yes. But you're going to have to code it. You can use OPENROWSET() to retrieve the excel file and you can do whatever you want from there. To do this automatically, you're going to create a job and a predefined schedule for it to execute.

        Good Luck!!!

        ~~ CK

        Comment

        Working...