daily report

  • I have to supply a daily report. I have written the correct query in T-SQL. Is there a way to use SQL Server to supply a daily CSV file or Excel file with the results?

    I'm trying to avoid using Crystal Reports 🙂

  • http://msdn.microsoft.com/en-us/library/ms190307.aspx

    Section B at the bottom will get you started if you want to create a job and schedule it.

    The best thing to do is set up Reporting Services and learn the basics of that. It is extremely easy to set up and you can scale it out when needed.

  • Another option is to use bcp to create the csv file or SSIS for any of the file options and possibly sending it via email.

    SSRS seems overkill for this task, but could be worth it if you need better format.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • inevercheckthis2002 (7/16/2014)


    I have to supply a daily report. I have written the correct query in T-SQL. Is there a way to use SQL Server to supply a daily CSV file or Excel file with the results?

    I'm trying to avoid using Crystal Reports 🙂

    What will be done with this daily report? Does it get emailed to a group of people or do they dip a common file somewhere? And, since it's "just" a report, does it actually need to be in an Excel file or is that what's being used to just make things "pretty"?

    --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)

  • Jeff Moden (7/16/2014)


    What will be done with this daily report? Does it get emailed to a group of people or do they dip a common file somewhere? And, since it's "just" a report, does it actually need to be in an Excel file or is that what's being used to just make things "pretty"?

    It will be emailed to a researcher. Excel is preferred, CSV would be acceptable.

  • Another option is to embed the SQL query into Excel. Your researcher, with the proper access and permissions to the SQL database, can then just refresh the spreadsheet when he needs it.

  • The best thing to do is set up Reporting Services and learn the basics of that. It is extremely easy to set up and you can scale it out when needed.

    Thanks - I was able to get this done using Reporting Services.

    The Stairway to SQL Server Reporting Services[/url] was very helpful.

  • Just another way to do this with Powershell:

    Invoke-Sqlcmd -Query "SELECT * FROM your_table;" -ServerInstance yourserver -Database yourdatabase | export-csv your.csv

    It can also be scheduled as you will any other task.

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

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