How to Export a Table Data to a PDF File in SQL?
Last Updated :
26 Apr, 2022
SQL Server is a versatile database. It is used across many industries. We can use AZURE data studio as well as SQL Server Management Studio for doing various operations (DDL, DML, Stored Procedure, Trigger preparations) etc., SQL Server supports the portability of data using the EXPORT option. By default, both tools support exporting data to CSV, XSL, or flat-file format. This article let us see how to export table data to a PDF file.
Let us start that by creating a database, table and proceed
Step 1: First we create a database.
Query:
-- DATABASE CREATION
CREATE DATABASE GEEKSFORGEEKS
GO
Step 2: Now we create a table.
Query:
-- MAKE DATABASE ACTIVE
USE GEEKSFORGEEKS
--CREATE A TABLE
CREATE TABLE [dbo].[AuthorDetails] (
[ID] INT NOT NULL,
[AUTHORNAME] VARCHAR (20) NULL,
[ADDRESS] VARCHAR (20) NULL,
[NOOFPOSTS] INT NULL,
[SKILLSETS] VARCHAR (100) NULL
);
Step 3: After creating a table, we insert values into the table.
Query:
--INSERT DATA INTO THE TABLE
INSERT INTO AuthorDetails (ID,AUTHORNAME,ADDRESS,NOOFPOSTS,SKILLSETS)
VALUES (1,'GEEKA','CHENNAI',50,'JAVA,PYTHON,MONGODB');
INSERT INTO AuthorDetails (ID,AUTHORNAME,ADDRESS,NOOFPOSTS,SKILLSETS)
VALUES (2,'GEEKB','CHENNAI',50,'JAVA,MONGODB,SQL SERVER');
INSERT INTO AuthorDetails (ID,AUTHORNAME,ADDRESS,NOOFPOSTS,SKILLSETS)
VALUES (3,'GEEKC','CHENNAI',20,'PYTHON,MONGODB,ORACLE');
INSERT INTO AuthorDetails (ID,AUTHORNAME,ADDRESS,NOOFPOSTS,SKILLSETS)
VALUES (4,'GEEKD','CHENNAI',100,'JAVA,PYTHON,MONGODB,ORACLE,SQL SERVER');
INSERT INTO AuthorDetails (ID,AUTHORNAME,ADDRESS,NOOFPOSTS,SKILLSETS)
VALUES (5,'GEEKE','BANGALORE',50,'ANDROID,SWIFT,MONGODB');
Step 4: To see inserted values we use the following queries.
Query:
-- SELECT THE DATA
SELECT * FROM AuthorDetails;
Output:
Step 5: By default, Azure data studio and SQL Server Management Studio supports for exporting of data to CSV, XLS and flat file. We can able to export the table data to PDF once this process is done. In SQL Server Management studio, we will get additional options as shown below:
- First, click on Data Pump and then select the Export Data option
- After that select PDF Export format from the window.
- In this step select a server connection, a database and its schema, table(s), and view(s) that you want to export, and click Next.
- On the Output settings page, you have two main options:
- Export data into separate files, where you specify the path to the folder in which they will be saved.
- Export data into a single file, where you specify the path and the file name. We will find the list of files to be exported in the Exported files preview box.
- Now we can able to get the pdf data.
Similar Reads
How to Export SQL Server Data to a CSV File?
Here we will see, how to export SQL Server Data to CSV file by using the 'Import and Export wizard' of SQL Server Management Studio (SSMS). CSV (Comma-separated values): It is a file that consists of plain text data in which data is separated using comma(,). It is also known as Comma Delimited Files
2 min read
How to Export SQL Server Data to a Text File Format?
Exporting SQL Server data to a text file is a common task that is used in data migration, data sharing, etc. SQL Server provides several methods to export data to a text file format, including using the SQL Server Management Studio (SSMS), the SQL Server Command Line Tool (sqlcmd), and the SQL Serve
4 min read
Export SQL Server Data From Table to CSV File
SQL Server is a very popular relational database because of its versatility in exporting data in Excel, CSV, and JSON formats. This feature helps with the portability of data across multiple databases. Here, we will learn how to export SQL Server Data from a table to a CSV file. Tools like Azure Dat
3 min read
How to Import and Export SQL Server Data to an Excel File?
SQL Server is very popular in Relational Database and it is used across many software industries. Portability of data is a much-required feature of any database. i.e. Database should support features like exporting database data to Excel/CSV/JSON and also should import data from them. In this articl
3 min read
How To Export Data As PDF in Angular?
Exporting data in Angular to PDF is a common requirement for applications that handle reports, invoices or downloadable content, in this article, we'll explain how to manually export data from an Angular application to PDF using jsPDF, a popular JavaScript library for creating PDF documents.Prerequi
3 min read
How to Export Database and Table Schemas in SQLite?
Exporting database schemas in SQLite is an important task for database management, enabling functions like data backup, recovery, migration, and auditing. In this article, We will go through the process of exporting database and table schemas in SQLite by understanding various examples to manage SQL
4 min read
How to Export Data From SQL Server to Flat File in SSIS?
In this article, we will learn how to Export Data From SQL Server To Flat File in SSIS. For this, we are going to create a package to select the data from the SQL server database and export SQL Server table data to the Flat File in the local drive. Prerequisites:Make sure Visual Studio 2019 is insta
3 min read
Export SQLite Database To a CSV File
SQLite is an embedded database that doesn't use a database like Oracle in the background to operate. It is written in C language and is used by developers who embed a lightweight database over the existing application, browser, or embedded systems. The main features of SQLite are that it is a tiny,
5 min read
How to Export Schema Without Data in PL/SQL?
In database management, there are times when you need to export the structure of your database objects such as tables, views, and procedures without including the data. This can be useful for creating backups, migrating databases, setting up development or testing environments, or sharing your schem
4 min read
How to Export Database Schema Without Data in SQL?
Database Schema specifies the structure of a database with its components like tables, columns, and indexes. Exporting data in SQL is an essential task in database management used to perform functions like data backup, recovery, migration, data analysis, performance optimization, compliance, auditin
4 min read