+ Reply to Thread
Results 1 to 14 of 14

SQL to Excel

  1. #1
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    SQL to Excel

    Hi,

    I need help regarding a query I run from MS SQL and pull the data in Microsoft Excel 2010.

    I have inserted another worksheet so one of our user can add more columns to analyse cost or reason for returns/failures.

    When return department add another line to an existing data in MS SQL and the other user refresh the excel spreadsheet then manually added columns

    go out-of-sync.

    Is there anyway when a user refresh the RAWDATA or any changes on SQL table then it should sync my formatted worksheet.

    One sheet has got all rows from SQL table and Formatted sheet has got extra columns we use.

    We could refresh the Rawdata columns and formatted columns sync with Rawdata worksheet. But when an extra line or product added to previous order id then

    formatted columns go out of sync for example

    Id ProductName Manual column
    2 Tyre Refund
    3 Tubes Faulty
    4 Tools Exchange

    When another product that has two orders and added on the system

    Id ProductName Manual column
    2 Tyre Refund
    2 Tyre Tubes Faulty
    3 Tubes Exchange
    4 Tools

    It is a bit complicated to explain as well. Thanks in advance or let me know if I have not made any sense.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    What do you mean by "out of sync" exactly?

    Also, does your second table look exactly like the first table - except for the extra columns (more specifically, does it have the same number of rows, with just more column details?)


    You might try just adding the calculated columns to the right hand side of the query table. They should remain there upon refresh - I think you need to adjust the "connection properties" to keep the column order or something like that. I've done that in the past, but not for some time.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    That is what I need not sure where to start.
    at the moment I have two worksheets one is from sql and the second copy of first worksheet and my calculation. Is there a way you could recall how to fix it?

    Thanks,

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    Can you post an example of the file in some way?

    Basically you can just right-click-insert columns to the query table, then author the formulas as needed in the new columns.

    NOTE: This is not using a second table - I'm talking about adding to the query table. After you add the columns, click somewhere on the query table so you get the "Table Tools" area to show up in the ribbon. Go to 'Properties' in the "External Table Data" area and check the box to preserve column order. That should make the changes (new columns you added) persist upon refresh.
    Last edited by GeneralDisarray; 04-20-2015 at 12:58 PM.

  5. #5
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    What would you need? Excel file or sql querying?

    I could upload it tomorrow for you.

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    Ok, I guess just the file you have with the two different tables. I think I could put the formulas into just the one (query) table and send it back to you to try a refresh.

  7. #7
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    I have attached the file and thanks.
    Last edited by gazy007; 04-23-2015 at 05:19 AM.

  8. #8
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    Any luck with it yet?

  9. #9
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    hello again, I don't see an attachment. Can you try again?

  10. #10
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    Hi,

    I have attached it again.
    Attached Files Attached Files

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    Ok, try refreshing the query table - the formulas I added to columns O and P on the far right, should refresh with the table.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    is it possible to add just text on the new columns such as how much time it took to inspect and the labour cost and each row should sync with credit request number row. It would avoid mistakes or accidents on the spreadsheet.

  13. #13
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: SQL to Excel

    you can add just text - but did the formulas I added persist through a refresh?

  14. #14
    Registered User
    Join Date
    04-20-2015
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    8

    Re: SQL to Excel

    Quote Originally Posted by GeneralDisarray View Post
    you can add just text - but did the formulas I added persist through a refresh?
    What happens when a line from from query or a row is deleted or column number change? Would that text stick/sync with that particular account number?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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