Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Write Reports from SQL to Disk (Even HTML!)

By michael1047, 2013/05/21


Ever need to write reports out to a folder? I have found that creating output files are SA-WEET! (and easy too) The sample script uses BCP to create an HTML file.

This process works well for reports that need to be generated nightly and take too long to run in real time.  Use an SMTP mail agent, and ALAS web based mail!


First open the script and change MYDATABASE to your database.

Second, add the script to your database then run the following:
  --Create the HTML file
  usp_writeSysObjectReport 'C:\sysobjects.html'
  --See the contents
  master..xp_cmdshell 'type c:\sysobjects.html'

  --Run this to clean up (uncomment)
  --master..xp_cmdshell 'erase c:\sysobjects.html'

Summary:
You can use BCP to create HTML documents and/or HTML mail. Can create many reports fast! You could modify the output to push it to a web server.

Total article views: 4109 | Views in the last 30 days: 16
 
Related Articles
FORUM

Report Script...

How to generate a completely report script...

FORUM

Create Login Script

Error with Create Login Script

SCRIPT

Generate Drop / Create Script for views, stored Procedures

This Script generates drop and create scripts for views or stored procedures.

FORUM

Script to create datestamp folder causing issue

Script to create datestamp folder causing issue

FORUM

How to Create a Report From Report Model in 2008?????

How to Create a Report From Report Model in 2008?????

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones