Results 1 to 2 of 2
  1. #1
    ASWilliams is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2016

    Not exists

    Hello SQL Forum,

    I've written a query that bulk inserts some data into a temp table then imports new records into an existing table using NOT EXISTS. My query is as follows:

    Create table #StagingForAccUpdates
    ISOWk bigint,
    SurrID bigint,
    CustName nvarchar(200),
    CustNum numeric(10,0),
    StartDate date,
    CustType nvarchar(50),
    PaymentTerms nvarchar(10),
    PayTermsType nvarchar(1),
    WeeklyCreditLimit nvarchar(20),
    Segment nvarchar(50),
    Book nvarchar(20),
    AccStatus nvarchar(50)
    BULK INSERT    #StagingForAccUpdates FROM 'Z:\MyFolder\MyFile.txt' WITH (FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n', FIRSTROW = 2)
    INSERT INTO tblCustomerAccounts(SurrID, CustomerType_ID, AccountNumber, CompanyName, StartDate)
    SELECT SurrID, CT.ID, CustNum, CustName, StartDate
    FROM #StagingForAccUpdates ST
    JOIN tblCustomerTypes CT
    ON ST.CustType = CT.CustomerType
                        SELECT *
                        FROM tblCustomerAccounts CA
                        WHERE CA.SurrID = ST.SurrID
    When I ran the script some new records were imported (as expected) but 4 remain. To validate the SurrIDs, I put the values into a spreadsheet and was able to VLOOKUP and identify the IDs in question.

    Is there a specific reason why these few rows might not get identified using the method outlined above?

    Many thanks

  2. #2
    NoellaG's Avatar
    NoellaG is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Hi, I think it would be simpler and work better if you use an outer join thereand test for null values.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2013, 02:14 PM
  2. Update Only Where Value Exists
    By Lorlai in forum Queries
    Replies: 2
    Last Post: 03-06-2012, 11:48 AM
  3. If table exists then
    By SorenIX in forum Programming
    Replies: 2
    Last Post: 06-26-2011, 08:42 AM
  4. Not Exists Between Query
    By Pells in forum Queries
    Replies: 5
    Last Post: 11-08-2010, 06:13 AM
  5. Add columns if not exists
    By ysrini in forum Access
    Replies: 1
    Last Post: 02-16-2010, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums - Senior Forums