Solved

How To Create a PDF from a stored procedure

Posted on 2014-02-20
3
1,070 Views
Last Modified: 2014-02-24
is there a way i can write a stored procedure in sql server to generate a sql result in a
PDF  or excel file??  (sql server db 2012)
0
Comment
Question by:eoswin
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Zberteoc
ID: 39874978
No. In SQL Reporting Services you have the option to convert any report in excel or in PDF format but directly from SQL server in a stored procedure is not the place and it was never meant to be. This should be done from an application.

You can however export in CSV format a result set, which can be easily opened in Excel. You can find a lot of examples on the net.
0
 
LVL 3

Accepted Solution

by:
smilieface earned 500 total points
ID: 39875603
You can make it export to Excel using something like this
INSERT INTO OPENROWSET 
   ('Microsoft.Jet.OLEDB.4.0', 
   'Excel 8.0;Database=c:\MyFile.xls;','SELECT Name, City, Zip FROM dbo.Customer')

Open in new window


You can also use BCP to create a CSV file and open that in Excel.

PDF is harder, but I'm sure there are way to do it using a CLR and running the output of a query through a converter.
0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 39883040
What was wrong with my answer?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this article I will describe the Detach & Attach 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.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

26 Experts available now in Live!

Get 1:1 Help Now