Creating a PDF from a Stored Procedure
http://www.sqlservercentral.com/columnists/mivica/creatingapdffromastoredprocedure.asp
...全文
29219打赏收藏
T-SQL 存储过程创建 PDF 格式文件(报表) [推荐]
仅引用了 FSO,PDF 格式可以自己写,就像标志语言: Creating a PDF from a Stored Procedure http://www.sqlservercentral.com/columnists/mivica/creatingapdffromastoredprocedure.asp
DECLARE SysKursor INSENSITIVE SCROLL CURSOR
FOR SELECT code FROM #pdf ORDER BY idnumber
FOR READ ONLY
OPEN SysKursor
FETCH NEXT FROM SysKursor INTO @trenutniRed
WHILE @@Fetch_Status = 0
BEGIN
EXECUTE @ole = sp_OAMethod @file, 'WriteLine', Null, @trenutniRed
FETCH NEXT FROM SysKursor INTO @trenutniRed
END
CLOSE SysKursor
DEALLOCATE SysKursor
DELETE FROM psopdf
EXECUTE @ole = sp_OADestroy @file
EXECUTE @ole = sp_OADestroy @fs
Creating a PDF from a Stored Procedure
Regular Columnist : M Ivica
Posted: 08/26/2003
More Articles From This Columnist
14089 Reads
Add Article to Your Virtual Briefcase (What is this?)
Article Rating Total number of votes [183]
--------------------------------------------------------------------------------
This Content Sponsored by: Is SQL the Center of your Universe?
SQLCentric is a comprehensive web-based network database monitoring and alert system. - brought to you by Pearl Knowledge Solutions, Inc.
http://www.pearlknows.com
This article explains how to create a a stored procedure that will in turn create a simple column based report in PDF without using any external tools or libraries (and their associated licensing costs!).
SQL2PDF makes a PDF report from text inserted in the table psopdf ( nvarchar(80) ). First a table named psopdf should be created.
CREATE TABLE psopdf (code NVARCHAR(80))
After that create the stored procedure SQL2PDF.
SQL2PDF.TXT
And table psopdf has to be filled with your data as shown in examples below.
At the end the stored procedure is called using the file name only (not extension).
EXEC sql2pdf 'fileName'
The result is in your C:\ directory.