+ Reply to Thread
Results 1 to 12 of 12

Running a bunch of query on MS SQL database

  1. #1
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    782

    Running a bunch of query on MS SQL database

    I have created a VBA loop, and SQL statement is inside the loop. The code runs fine, no issue at all. So this is for workplace task, I have permission to use the data (as I can run query on the database).

    But my question: What would IT admin (or database Admin) think of an employee running thousands of query on the database within 20 minutes? Does it matter? Is it a normal thing for employee to do? Do they think the action as some kinds of "database attack"? Or I should intentionally place a few seconds pause before running next query? If I add 3 seconds to each query and there is 1000 query, then it adds additional 3000 seconds (50 minutes) of running time, not a good option too.
    Last edited by VAer; 11-06-2024 at 09:15 AM.

  2. #2
    Registered User
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2410
    Posts
    185

    Re: Running a bunch of query on MS SQL database

    I think, it's no matter at all.
    Administrator would have granted you a proper authority to query for your task, like read only.
    But, you need to reduce query time.

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,501

    Re: Running a bunch of query on MS SQL database

    1000 queries?????

  4. #4
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    782

    Re: Running a bunch of query on MS SQL database

    Same query, but changing the value for WHERE statement, inside the VBA loop (e.g. For i = 1 to 1000 SELECT *** From Table_name Where Group_number = i )

    I was just trying to say running query many times on the database within 20 minutes, to IT admin, each query running may be counted as one query.
    Last edited by AliGW; 11-06-2024 at 12:39 PM. Reason: Please STOP quoting unnecessarily!

  5. #5
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,501

    Re: Running a bunch of query on MS SQL database

    Import it once, then do your 1000 iterations over the already loaded array

  6. #6
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    782

    Re: Running a bunch of query on MS SQL database

    Then there could be quite a few millions of records if importing it once, which exceeds excel sheet row limit.

    If there is no issue on IT admin end, I will keep current code. Dealing with multiple millions of records will require additional VBA code.
    Last edited by AliGW; 11-06-2024 at 12:40 PM. Reason: Please STOP quoting unnecessarily!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,706

    Re: Running a bunch of query on MS SQL database

    @VAer

    Once again, please STOP quoting unnecessarily.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  8. #8
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,501

    Re: Running a bunch of query on MS SQL database

    Maybe export the sql table to a csv file and from there use vba to handle it

  9. #9
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    782

    Re: Running a bunch of query on MS SQL database

    I heard of cvs a lot, but no experience with it, not IT folk. Manually export file to CVS file? Do you mean excel file save as CVS file? Does it also have row limit per sheet?

  10. #10
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,501

    Re: Running a bunch of query on MS SQL database

    It is generally a textfile(flat file of your data). Yiu can iterate over this file, without using heavy calls on the sql database

  11. #11
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    782

    Re: Running a bunch of query on MS SQL database

    I don't know much about interacting with text file via VBA, so I can do it now.

    But it is something I should learn to use VBA on text file.

    Any good source to learn the skill set? Such as:
    • Export data from MS SQL to text file.
    • Look into text file to find some data (basically, how to run SELECT * From *** WHERE *** on text file)?

    Edit: I have made a new post (kinda new topic): https://www.excelforum.com/excel-pro...text-file.html
    Last edited by VAer; 11-06-2024 at 04:13 PM.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2412 (Windows 11 24H2 64-bit)
    Posts
    88,706

    Re: Running a bunch of query on MS SQL database

    You need to go back and mark all previous threads as solved, please.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] What's difference between a database query and a database table query?
    By sumdumgai in forum Excel General
    Replies: 5
    Last Post: 09-27-2012, 05:30 PM
  2. Database Query-possible to link a spreadsheet to a database
    By COYF in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-04-2010, 09:37 AM
  3. Running a database query with contents of cell
    By davidrough in forum Excel General
    Replies: 4
    Last Post: 11-16-2009, 01:16 PM
  4. Replies: 3
    Last Post: 08-14-2006, 05:10 PM
  5. Replies: 2
    Last Post: 03-08-2006, 04:45 PM
  6. Database Query-a query that reads data from MS Access
    By Osmar Mateus in forum Excel General
    Replies: 4
    Last Post: 01-29-2006, 04:10 PM
  7. Replies: 4
    Last Post: 11-29-2005, 09:44 AM
  8. Type Mismatch when running query on SQL Database
    By Neily in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2005, 11:05 AM

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