--Assume the database name is db_demo and table with below structure holding the blob data to be exported
create table tbl_exporttopdf
(attach_id int,
attach_name varchar(50),
attach_fdata image)There are many ways to export the blob/image column data into pdf file .Below is the example using xp_cmdshell command of sql server. If the xp_cmdshell is not configured in your db. follow the below steps to configure.
--steps to configure xp_cmdshell ..start
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
--steps to configure xp_cmdshell ..End
--query to export data into pdf file at "C:\exportdir\" folder .In the below query i have exported the blob data whose attachment id is 1 to the
--file yourfile.pdf
EXEC master..xp_cmdshell 'BCP "SELECT attach_fdata FROM db_demo.dbo.tbl_exporttopdf WHERE attach_id= 1 " queryout "C:\exportdir\yourfile.pdf" -T -N'