Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL generating Word Document

Status
Not open for further replies.

andyc209

IS-IT--Management
Dec 7, 2004
98
0
0
GB
I have found a lot of info on inserting data from word and inserting whole documents into sql but not the other way around.

I have a template word document that is an invoice and i want SQL to be able to run a SP that will insert data into this document on an automated basis. I have seen mailmerge methods but that involves user interaction. I can write the SP with the data collection and automation i just need to know how i can point SQL at this specific word doc, insert the data and then give it a filename and save it.

thanks for any help
 
You wouldn't do that from the SQL server, but use mailmerge via via Word.Application automation. That said, it depends what programming language you use on how to automate word, but eg that's possible in .NET via a Word document project type.

To be able to do office automation server side you would need to lower serveral security barriers, to exxecute code, enable COM and mcuh more, it's usually not the way to go, but do it as mailmerge from the client side, mail merge loads data and creates documents, not SQL Server automates Word.

Bye, Olaf.
 
You need a report. Word mail merge is useful when you want to run the task manually. If you want to automate it you need to use a report, which will be run for each record returned by the stored procedure. The whole idea of automation is to start a windows service and set it to do some work for you. You can write an app , which will automate Word, but Microsoft strongly recommends to not do that. If you have SQLServer, you also have a license for SSRS. If the license is Enterprise you can set a data driven subscription. If you don't have Enterprise license you can find some tools that can do this for you. Again , this is possible , but Word is not the right choice.

Viewer and Scheduler for Crystal reports, SSRS and Dynamic Dashboards.
 
MS Word can do that for you, using the embedded VBA (VB for Applications) language, as also used in macro's, or in fact any word-processing tool that does mail-merge based on an ODBC data source.
 
I would recommend set up SSRS and create a subscription for delivery report in word format to any share drive or email...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top