Solved

SQL Output Report

Posted on 2009-07-10
4
226 Views
Last Modified: 2012-05-07
I would like to have a stored procedure to product an output report to a text file.  Is this possible?

Table1

PN               MonthGenerated
---               ---------------------
12345         Apr
22345         Apr
11111        Mar
22222        Mar
11211       Jun


Output report

"Monthly Generated Report"

Month                  Counts
-------                  ---------
Mar                     2
Apr                    2
Jun                     1
0
Comment
Question by:Fairfield
  • 2
4 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24824190
You can use the OSQL utility to do that. It is a command like utility that can run against your SQL server, store it as a batch file and schedule it through windows scheduler.
Here is more info on the OSQL utility: http://technet.microsoft.com/en-us/library/aa213090(SQL.80).aspx
Hope this helps.
P.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24824192
usq sqlcmd utitliy
SQLCMD -S ServerName -d DatabaseName -E -Q"select * from tablename "  -o "E:\output.txt"
0
 

Author Comment

by:Fairfield
ID: 24824403
Is there a way to combing multiple reports into one single report?
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 24824489
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question