Need help with SQL Syntax

  • Hello,

    Need some help with a import process. I have a customer table that will be updated on a daily basis. I will start with a file of all my customers information that will be uploaded to the table. Going forward in the daily file I will only recieve records for those customers that information changes and new customers. Can anyone give me example syntax so when the new file comes in it will first look in the table to see if the customer number already exists. If so update that record. Next and I forgot to mention this part if the customer number doesn't exist look in another field to see if the customer number is there b/c in this case the customer recieved a new number (lost/stolen account), if the customer number is found update the record with new customer number and record information. Last if neither of the two instances are true append the new record to the table. Any help will be wonderful and any questions will be answered. Thanks!

  • What have you tried so far and where you get stuck?

    In general there are two options: using SSIS or plain T-SQL.

    Basically, the following steps are required:

    Load the file

    Validate data

    Lookup the customer number in the target table using both possible numbers

    Finally, perform a MERGE into your target table.

    I'd probably go with SSIS for that task.

    A personal note: Without showing what you've tried so far you're leaving the impression to use this forum for some kind of freelancing help at no cost...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • I hadn't tried anything. I'm so new to SQL that I didn't know where to start. Thank you for pointing me in the right direction. I do apologize for the perception of trying to get something for free. I would actually be open to paying for a solution if you were interested. Thanks!

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

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