+ Reply to Thread
Results 1 to 7 of 7

SQL insert or update

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    SQL insert or update

    Currently i use
    Please Login or Register  to view this content.
    to insert data into a table, the only problem is that when i update the table from my excel worksheet it creates duplicate files

    if i use update it will not create new entries where they currently do not exist..

    i need a overwrite command that also creates a new record where an old is not found!

    can i use a update where (blablabla) and if these conditions are not met then insert?


    thanks guys,


    Jonathan

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: SQL insert or update

    Why not put a command line into your script to delete the table contents before you run your Insert SQL statement. Then in effect, you have run an overwrite. Does the data you are trying to bring into your table contain only new data or does it also have the historical data that was already loaded to your table. If only new data, then you could run an APPEND statement.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: SQL insert or update

    i had thought about that, however the input will only be for a few fields in a record.. if i delete the record, then i will lose the data input from other sources!

  4. #4
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: SQL insert or update

    also don't i have to run an append query from access, not excel?

  5. #5
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: SQL insert or update

    i think what i want is

    Please Login or Register  to view this content.
    and when this does not find anything to update

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: SQL insert or update

    so something like this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: SQL insert or update

    or this maybe?

    Please Login or Register  to view this content.
    but these all throw errors

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1