-3

I have stored a PDF file in SQL Server table with the following commands now I want to get the same file from the table can you please tell me how do I get this PDF file in the readable format.

create table attachments (
    srno int
    , description varchar(1000)
    , attachment_type varchar(30)
    , attachment varbinary(max)
); 

insert into attachments
values (1, 'Holiday List 2022', 'PDF'
   , (select * from Openrowset(BULK 'C:\Temp\export_holiday_list.pdf', SINGLE_BLOB) as pdf));

select * from attachments;
Dale K
  • 25,246
  • 15
  • 42
  • 71
  • 1
    please edit your code with additional information – nbk Aug 10 '23 at 16:37
  • 1
    use a programming languags as php or c# vbnet aand so on to retrieve the information and save it in a file for example – nbk Aug 10 '23 at 16:40
  • 3
    Aside, storing files inside SQL Server is not a good idea and does not scale; your backups become larger, bloated and take longer; maintenance takes longer; restores take longer; files belong in the *file*system – Stu Aug 10 '23 at 19:20
  • 1
    What's wrong with `SELECT attachment FROM attachments WHERE srno=1`? Presentation of the PDF then is, well, up to the presentation layer. – AlwaysLearning Aug 10 '23 at 22:04

0 Answers0