Solved

How To Create a PDF from a stored procedure

Posted on 2014-02-20
3
1,236 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
[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
3 Comments
 
LVL 27

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 27

Expert Comment

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

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

622 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