+ Reply to Thread
Results 1 to 5 of 5

SQL Query to Sheet - 1 column behaving badly

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    SQL Query to Sheet - 1 column behaving badly

    Hello - I have a SQL query that is behaving a bit oddly. There are 8 fields in the DB, and currently about 1,500 rows so far (pretty small, I know).

    I've used this code before with no issues:

    DataA is the array that holds my SQL results. NumRec is the number of records being returned.
    Please Login or Register  to view this content.
    The first of the 8 columns (x) writes the 1500 rows (y) in about 1 second
    The second writes in about 13 seconds
    The third, fourth, fifth, sixths and seventh write in about 1 second each.

    The data in the second column is simply 3-4 alpha characters - the other columns are slightly larger texts fields and 1 date field. For example:
    Please Login or Register  to view this content.
    Am I missing something obvious? Alternately, is there a better way to just flash dump all of the data from the SQL table into my sheet?

    Many thanks for any help.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: SQL Query to Sheet - 1 column behaving badly

    Yes,
    Assuming that rs is the data returned from the SQL execution code.

    Sheets("Sheet2").Range("A2").CopyFromRecordset rs

  3. #3
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: SQL Query to Sheet - 1 column behaving badly

    Thank you...

    I know I'm doing something stupid... but the data I get back from SQL is in the Array, "DataA"
    Please Login or Register  to view this content.
    But nothing is written to the spreadsheet. I added a Watch for DataA, and I can see that the array does have all the results, though.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: SQL Query to Sheet - 1 column behaving badly

    I think it is Rst, not DataA

    DataA = Rst.GetRows(NumRec) ' returns the rows from Rst

  5. #5
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: SQL Query to Sheet - 1 column behaving badly

    Ah, I see the problem - thank you for your help.
    I wasn't creating the Rst object right (Set Rst = CreateObject("ADODB.Recordset"))

    Thank you again!

+ 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] Pivot Behaving Badly
    By callummcgrath in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-25-2017, 07:22 AM
  2. [SOLVED] Formula Behaving Badly in Two cases
    By glaskow4 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-17-2015, 03:54 PM
  3. [SOLVED] I badly need help please: Get data across multiple sheet
    By lati2008 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2014, 07:03 PM
  4. [SOLVED] MOD function behaving badly
    By mzg71 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-04-2013, 03:05 AM
  5. Excel 2007 : Pivot table behaving badly!
    By WanderingAround in forum Excel General
    Replies: 2
    Last Post: 04-26-2010, 08:25 AM
  6. Excel behaving badly
    By no_name in forum Excel General
    Replies: 1
    Last Post: 12-23-2005, 06:50 AM

Tags for this Thread

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