Results 1 to 7 of 7
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Update Statement On Linked Table With No PK

    I have an access 2013 datbase with a linked table to SQL Server. My issue is I am joining on this table in an update statement, but due to the no PK contraint I get an error of "The operation must use an updateable query"



    Unfortunately, I am unable to modify the DDL/Structure of the SQL table so I am forced to handle this on the Access side of things. I think I am using very basic syntax for my update statement
    Code:
    DoCmd.RunSQL ("UPDATE ET INNER JOIN [HSICust] ON [ET].[CustNum] = [HSICust].[CustNum] SET [ET].[CustNum] = 'CSP-03231', [ET].[Address] = [HSICust].[Address];")
    However, again due to the no PK constraint on the HSICust table the error is thrown. Is the best work-around for this to run a make-table query from the table HSICust and since it is a local table will be writeable, then join on the local table, then delete this table once the Update portion is completed?

    Or are there other alternatives that I have not considered?

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You are aware, I hope, that that update query (if it worked) would set every record in table ET to the same CustNum but all with different Addresses?

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    And FYI, if you join a local table to a SQL Server table, the performance may be terrible if the SQL Server table is large. Access won't be able to send the SQL to the server to be processed, so it will pull the whole table over the wire.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    Quote Originally Posted by John_G View Post
    You are aware, I hope, that that update query (if it worked) would set every record in table ET to the same CustNum but all with different Addresses?
    Yes - I am aware of that. I am taking one CustNum that has many rows and inserting it into a table ET to only be 1 Row. Then I just need to update the "filler" fields.

  5. #5
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    Quote Originally Posted by pbaldy View Post
    And FYI, if you join a local table to a SQL Server table, the performance may be terrible if the SQL Server table is large. Access won't be able to send the SQL to the server to be processed, so it will pull the whole table over the wire.
    I would be joining a local table to a local table. Well, creating a make table of the SQL Server linked table, and the table joining to is already a local access table.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If there's no better way that pulling the table down, I wouldn't use a make table. I'd have a local table that I emptied/repopulated. Offhand I can't think of a better way. I'm used to having control over the SQL Server structure.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I am taking one CustNum that has many rows and inserting it into a table ET to only be 1 Row.
    Sorry, but I'm not following you. The SQL you showed doesn't insert anything; it just updates 2 fields in row(s) that are already there. Before you run that Update query, how many records are in ET, and what is in them? Then, what do you want to change the data in them to? Again, if that query worked, you would get one CustNum with many different addresses, but they would mostly be addresses from other CustNums, and I suspect that is not what you intend.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-17-2015, 07:01 AM
  2. Replies: 3
    Last Post: 04-10-2015, 07:45 AM
  3. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  4. Replies: 1
    Last Post: 01-22-2011, 12:23 PM
  5. Update statement with linked table join
    By Guigui in forum Queries
    Replies: 6
    Last Post: 09-17-2010, 04:47 AM

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