Solved

SQL Output Report

Posted on 2009-07-10
4
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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