0

I'm trying to insert a .JPG into a SQL Server database using this query:

INSERT INTO Model (Id) 
    SELECT 1
    FROM Openrowset( Bulk 'C:\Desktop\boat.jpg', Single_Blob) as ProductPicture

I'm getting this error:

Operating system error code 3(The system cannot find the path specified.).

I have checked the file path and it seems to be correct.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AndroidAL
  • 1,111
  • 4
  • 15
  • 35

2 Answers2

2

2 possibe issues:

  • Permission. YOU are doing nothing - SQL Server is, so the SQL Server user needs permissions to access the file.

  • Locality. Just because YOU find the file at C:\Desktop does not mean that your SQL Server does. The SQL is executed ON THE SERVER, not on your client.

Given that the path includes DESKTOP it is likely both.

TomTom
  • 61,059
  • 10
  • 88
  • 148
1

OPENROWSET with a drive letter is referring to the drive on the SQL Server machine, not your PC.

For details of how to use a network share (for example to access your PC), see this MSDN

https://msdn.microsoft.com/en-au/library/ms175915.aspx#Anchor_3

And this for OPENROWSET in general

https://msdn.microsoft.com/en-us/library/ms190312.aspx

Liesel
  • 2,929
  • 2
  • 12
  • 18