Solved

SQL Output Report

Posted on 2009-07-10
4
223 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
encyps queries mssql 15 37
Square brackets 4 38
In or Between 2 44
SQL Server CASE .. WHEN .. IN statement - Syntax issue 4 49
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now