0

I have a table: Formats

with columns:

FileName,Document_binary,Format,UsedBy,Date and Id

Document column is VARBINARY(MAX).

There are some already loaded documents with names like: 0x504b34xxxx and so on, all of these are excel files that users can download from a site.

What I am trying to accomplish is to have this file formar, the file itself stored in the database for when a user needs the file go get it from the system as a download. Not the data contained in it but the file itself.

I need to do it manually without any interface.

I tried this below with no luck:

    INSERT INTO Formats
    (FileName, Document_binary,Format,UploadUser,UploadDateTime,Id)

    values

    ('Case_Project', * FROM OPENROWSET(BULK 'C:\Users\jhon\Desktop\Worksheet 
     in 6W2H update Jul2018 formato std.xlsx'), 
     'Template','jhon.doe',NOW,22)

Thank you

user3412266
  • 71
  • 1
  • 3
  • 8

1 Answers1

0
SELECT * INTO Formats (FileName, Document_binary,Format,UploadUser,UploadDateTime,Id)
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=C:\Users\jhon\Desktop\Worksheet_in_6W2H_update_Jul2018_formato_std.xlsx; HDR=YES; IMEX=1','SELECT * FROM [Sheet1$]');

Keep the file name without space.

sticky bit
  • 36,626
  • 12
  • 31
  • 42