I am trying to create a query script for SQL Server that will convert pdf file into varbinary data and store it into the SQL Table column which is varbinary(max). I also have to make sure it loops so it can do that for the next pdf file in that folder. This folder will only contain pdf files.
DECLARE @pdf VARBINARY(MAX)
SELECT @pdf = BulkColumn
FROM OPENROWSET(BULK N'C:\Users\......\YourFile.pdf', SINGLE_BLOB) AS Document;
SELECT @pdf, DATALENGTH(@pdf)
INSERT INTO dbo.YourTable(PDFContents) VALUES(@Pdf)
GO
master.sys.xp_dirtree
stored proc.