Q:

inserting remote pdf into sql using openrowset

I am trying to insert a pdf file on a remote machine into a local sql server table.
The docTable has 2 columns. docName is varchar (50) and docContent is varbinary(max)
 insert into docTable(docName, docContent) 
 select 'sr123.pdf', '* from OPENROWSET(BULK '\\server01\e$\DocStore\InvoiceDocs\sr123.pdf', SINGLE_BLOB)'

This is giving an error 
 Incorrect syntax near '\'.

I am not sure if this is a single quote issue or a security issue while my local sql account is trying to access the remote file?

A:

Try this...
 INSERT INTO docTable(docName, docContent) 
 SELECT 'sr123.pdf'
       , * FROM OPENROWSET(BULK '\\server01\e$\DocStore\InvoiceDocs\sr123.pdf'
                           , SINGLE_BLOB)

You had extra single quote ' wrapping your from clause.

