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!)
SQL
CREATE TABLE psopdf (code NVARCHAR(
After that create the stored procedure SQL
SQL
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 sql
The result is in your C:\ directory
EXAMPLE
INSERT psopdf(code) SELECT SPACE(
INSERT psopdf(code) SELECT SPACE(
INSERT psopdf(code) SELECT SPACE(
INSERT psopdf(code) SELECT
INSERT psopdf(code) SELECT SPACE(
INSERT psopdf(code) SELECT
INSERT psopdf(code) SELECT
+ SPACE(
INSERT psopdf(code) SELECT REPLACE(SPACE(
INSERT psopdf(code) SELECT
+ SPACE(
INSERT psopdf(code) SELECT
+ SPACE(
INSERT psopdf(code) SELECT REPLACE(SPACE(
INSERT psopdf(code) SELECT SPACE(
After INSERT call the stored procedure with file name demo
EXEC sql
The result is in your C:\ directory
EXAMPLE
Second example uses a database pubs
USE pubs
INSERT psopdf(code) SELECT t
+
authors t
After INSERT call the stored procedure with file name demo
EXEC sql
>The result is in your C:\ directory
sql
CREATE PROCEDURE sql
@filename VARCHAR(
AS
CREATE TABLE #pdf (idnumber INT IDENTITY(
CREATE TABLE #xref (idnumber INT IDENTITY(
CREATE TABLE #text (idnumber INT IDENTITY(
DECLARE @end VARCHAR(
@beg VARCHAR(
@a
@a
@ad VARCHAR(
@cr VARCHAR(
@pr VARCHAR(
@ti VARCHAR(
@xstr VARCHAR(
@page VARCHAR(
@pdf VARCHAR(
@trenutniRed NVARCHAR(
@rows INT
@ofset INT
@len INT
@nopg INT
@fs INT
@ole INT
@x INT
@file INT
@object INT
SELECT @pdf =
SET @page =
SET @nopg =
SET @object =
SET @end =
SET @beg =
SET @a
SET @a2 = '>>
SET @ad =
SET @cr = CHAR(
SET @pr = CHAR(
SET @ti = CHAR(
SET @xstr =
SET @ofset =
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #xref(code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (@end)
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (@end)
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (@end)
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (@end)
INSERT INTO #text(code) (SELECT code FROM psopdf)
SELECT @x = COUNT(*) FROM #text
SELECT @x = (@x /
WHILE @nopg < @x
BEGIN
DECLARE SysKursor INSENSITIVE SCROLL CURSOR
FOR SELECT SUBSTRING((code + SPACE(
FOR READ ONLY
OPEN SysKursor
FETCH NEXT FROM SysKursor INTO @trenutniRed
SELECT @object = @object +
SELECT @page = @page +
SELECT @len = LEN(@object) + LEN(@object +
INSERT INTO #pdf (code) VALUES (CAST(@object AS VARCHAR) + @beg)
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
SELECT @object = @object +
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (@end)
SELECT @ofset = @len +
INSERT INTO #xref(code) (SELECT SUBSTRING(
LEN(
LEN(
INSERT INTO #pdf (code) VALUES (CAST(@object AS VARCHAR) + @beg)
INSERT INTO #pdf (code) VALUES (@a
SELECT @object = @object +
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (@a
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
INSERT INTO #pdf (code) VALUES (
From:http://tw.wingwit.com/Article/program/SQLServer/201311/21997.html