Results 1 to 7 of 7
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284

    Combining SQL DELETE Statements Into One SQL String

    I have the following and it works perfectly and lightning fast - so no complaints there

    But I can't help but to wonder if there is a 'cleaner' way to write this - Perhaps a way to combine the DELETE Queries into one StrSQL


    Code:
    Dim conn As ADODB.Connection
    Set conn = New ADODB.Connection
    conn.ConnectionString = strConnection
    conn.Open
    StrSQL1 = "DELETE FROM dbo.ThisTable"
    StrSQL2 = "DELETE FROM dbo.ThatTable"
    StrSQL3 = "DELETE FROM dbo.HisTable"
    StrSQL4 = "DELETE FROM dbo.HerTable"
    
    With conn
      .Execute StrSQL1
        .Execute StrSQL2
        .Execute StrSQL3
      .Execute StrSQL4
    End With
    
    conn.Close
    Set conn = Nothing
    As Always - Thank You...

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Multiple SQL actions cannot be combined into a single executable string.

    Deleting data should be a rare occurrence.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Thanks June

    Just thought I'd ask...

    I agree with your deleting sentiment - However these are TempTables

    Thus these will get deleted often..

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yes, temp tables would be an exception. So these temp tables each hold very different data? Your db is split and these tables are in frontend?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Hey June ~

    Yes on the table differences - As for the location of the tables - these TmpTbls use to be FE - I have now moved all the tables to the SQL server
    and I'm using PassThrough's to manage & manipulate the data.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I never used SQLServer and not familiar with PassThroughs. This enables multiple users to utilize the temp tables without interfering with each other?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    As usual, you pose a good question, June - At the moment there will be only one user for this system at a time - How ever I am trying to avoid any conflict by creating a Qdf - Which is now the source of my next question for the group...

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

Similar Threads

  1. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  2. Delete Partial String HELP!!
    By Crawfordrider33 in forum Access
    Replies: 2
    Last Post: 05-15-2015, 11:31 AM
  3. Replies: 6
    Last Post: 08-10-2012, 02:28 PM
  4. Combining Two INSERT INTO Statements
    By WyattR in forum Programming
    Replies: 4
    Last Post: 07-04-2012, 09:29 AM
  5. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 08:36 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