+ Reply to Thread
Results 1 to 2 of 2

SQL Query loading in MS Query but not importing data to excel

  1. #1
    Registered User
    Join Date
    03-12-2012
    Location
    London
    MS-Off Ver
    Office 365 ProPlus 64 bit
    Posts
    35

    SQL Query loading in MS Query but not importing data to excel

    Hi All,

    I've written a query up in SQL, which runs perfectly fine in SQL Studio Manager & am trying to embed into excel using Microsoft query as I've done loads of times before.

    The query returns data within the MS Query preview window & when trying to import this data into a table in excel, it seems to be running for a few seconds & says "Getting data", but then no data appears & I just get static text saying "Query from [connection]" but no data.

    I assume this must be because excel doesn't appreciate some of the syntax of my query, but I can't seem to work out which bit.

    It uses temporary tables, joins & ISNULL but I'm sure I've used these before without error.

    See attached screenshots & the query itself.

    Any ideas?! Any insight would be very much appreciated.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: SQL Query loading in MS Query but not importing data to excel

    About the only advice I can offer is to check the command string. There might be a difference between the query you think Excel is using and the query it is actually using. I've had MS-Query rewrite some of my queries, particularly where clauses.

    Generally speaking, my queries are too complex to accept parameters, so I write the query and paste it to a column in an Excel table. Where I need a parameter like a date I put '&DATE' in the code. Then in column B I have a formula like =SUBSTITUTE(A4,"&DATE",Report_Date) where Report_Date is a named range on the spreadsheet, very often the string representation of a calculated date.

    There is a short bit of VB code that takes the translated SQL (in column B) and places it directly into the command string bypassing at least a part of MS-Query. You might want to try that. This article has a brief explanation and code at the end of it: http://www.utteraccess.com/wiki/index.php/MS_Query
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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] SQL Query loading in MS Query but not importing data to excel
    By sharper1989 in forum Access Tables & Databases
    Replies: 0
    Last Post: 05-19-2016, 09:31 AM
  2. Replies: 2
    Last Post: 11-28-2013, 02:27 AM
  3. Importing Data from Access into Excel using microsoft query
    By JessicaW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2013, 02:51 PM
  4. Importing query from Access, data changes in Excel!
    By bromero in forum Excel General
    Replies: 0
    Last Post: 02-17-2010, 01:15 PM
  5. Importing Access query into Excel:Microsoft Query
    By ge0rge in forum Excel General
    Replies: 3
    Last Post: 04-02-2009, 10:51 AM
  6. Replies: 5
    Last Post: 05-09-2006, 01:25 PM
  7. Importing data to Excel using MS Query
    By John in forum Excel General
    Replies: 1
    Last Post: 11-17-2005, 02:25 PM

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