create a button that will run a query and export it to excel

  • hi guys,

    please i need your help and thoughts;

    i have a query that i run every morning , i need to create a portal that i will give access to specific users so they can click a button that will run a query and export it to an excel sheet.

    any thoughts??

  • Hi,
    try to put the query in a sql job. Export the result to csv via job step and the user could import the csv file to excel.
    What do you mean with "portal", a web page or an application?
    Kind regards,
    Andreas

  • Do you have SSRS installed?  You could create a simple report based on the output of the query.

    You could then either set up a subscription which could run the report daily and export the results in Excel format.

    Or the user could run the report themselves from SSRS from Report Manager which is a web based portal.

    Regards
    Mark

  • What is your portal? What is it programmed in? Have you tried anything so far? What were the problems you encountered? We have very vague details here, which means that the answers you get here are going to be similarly vague, or users asking for more detail (I'm doing the latter). There are (probably) 100's of ways to do this, however, none of them, are going to be a simple "point and click" answer. SSRS and SSIS are both ideas. Using your application to export it is another (how it would do it is totally depending on your application).

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • jadraad91 - Friday, September 21, 2018 5:07 AM

    hi guys,

    please i need your help and thoughts;

    i have a query that i run every morning , i need to create a portal that i will give access to specific users so they can click a button that will run a query and export it to an excel sheet.

    any thoughts??

    How you do that depends heavily on how much work you are willing to do.   You could create a template spreadsheet in Excel that uses VBA code to pull the data into the spreadsheet, and optionally "pretty it up"...   You could do much the same thing in MS Access and then export the data into Excel from there, again, all using VBA code.   If you are looking for some easy 30 seconds and done scenario, that just doesn't exist.  The two options I referred to are probably among the easiest, but either one could take anywhere from a day or two to a week or so, depending on the creator's skill level with VBA. and familiarity with the Object Model for Excel and/or Access, as well as ADO code for using SQL.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Give the users a spreadsheet where they can click a button, have it run a stored procedure, and put the results in the same spreadsheet.  Removes the onus from you and allows them to get the data they want when then want... and IF they want... a lot of users "gotta have it" until they get it and when they're the ones that have to get it, suddenly they no longer need it. 🙂  Just sayin...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Another easy option is to build the report in SSRS. The use the SSRS report schedulrer to automatically execute the report at a specified time and save it out to a network share as an Excel spreadsheet..

  • Thom A - Friday, September 21, 2018 6:39 AM

    What is your portal? What is it programmed in? Have you tried anything so far? What were the problems you encountered? We have very vague details here, which means that the answers you get here are going to be similarly vague, or users asking for more detail (I'm doing the latter). There are (probably) 100's of ways to do this, however, none of them, are going to be a simple "point and click" answer. SSRS and SSIS are both ideas. Using your application to export it is another (how it would do it is totally depending on your application).

    Dear ,
    among all replies i found yours to be the most professional and close to my thinking,
    i still  haven't tried anything, i'm still thinking what to choose (access, visual studio windows application...)
    all i want is a button which inside it a query that will run and if possible export to excel.
    i was thinking  about a windows application where i can connect it to sql or access  so i can write the query.
    thank you for your time and hope that you'll reply again.
    Best Regards,
    Jad.

  • jadraad91 - Tuesday, September 25, 2018 12:51 AM

    i still  haven't tried anything, i'm still thinking what to choose (access, visual studio windows application...)
    all i want is a button which inside it a query that will run and if possible export to excel.
    i was thinking  about a windows application where i can connect it to sql or access  so i can write the query.
    thank you for your time and hope that you'll reply again.
    Best Regards,
    Jad.

    That dosen't give us much (anything) to provide an answer to help; considering you don't know what tool you want to use. There have been several ideas given to you in the above post, so I suggest having a look at those are going from there. Decide on the method you want to use, then make a start. When/if you get stuck, reply here and let us know the problems you're having, and I'm sure someone who has already posted here will be happy to point you in the right direction or let you know where you went wrong.

    Personally, I think Jeff's input of using a distributed Spreadsheet would be one of the simpliest; takes the onus off you to provide it like he said. You can set up the macro, data connnection (what ever you feel works for you) and then have a button click to do all the work for you.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply