0

I am getting the following Operating system error:

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

The client machine is windows 10 and the MSSQL server is running on Ubuntu 20.04.

The query is

Declare @JSON varchar(max)
SELECT @JSON=BulkColumn
FROM OPENROWSET (BULK '/home/user/RC_2015-01.json', SINGLE_CLOB) import
SELECT *
FROM OPENJSON (@JSON)

The file /home/user/RC_2015-01.json exists locally on the MSSQL server. I did also did a sudo chown mssql RC_2015-01.json.

The file permissions are as follows:
-r-xr-xr-x 1 mssql user 31648374104 Jun 24 23:54 RC_2015-01.json

Thom A
  • 88,727
  • 11
  • 45
  • 75
pundip
  • 27
  • 5
  • 2
    Does the `mssql` user or group have access to execute and read the directory `/home/user`? Though, normally, home directories have the default permissions of `755`, this isn't always the case. – Thom A Jun 30 '21 at 13:16
  • 2
    You could also try accessing the file as the `mssql` user. Use `sudo su mssql` to impersonate the user. Then use `cat` (or `tail` if it's a very large file) to try to read the contents: `cat /home/user/RC_2015-01.json` – Thom A Jun 30 '21 at 13:18
  • 1
    Ideally, however, I would suggest *not* storing data that the `mssql` user needs to access in the `/home` directory. Instead, put it somewhere that it explicitly has access to read and write in. This might mean creating a new folder in your root, or somwhere like the `/media` directory, or where SQL Server stores it's files (`/var/opt/mssql` on Ubuntu). – Thom A Jun 30 '21 at 13:28

1 Answers1

0

Thank you all. As suggested I impersonated mssql via sudo su mssql and copied the file to /var/opt/mssql.

The following query is now executing:

Declare @JSON varchar(max)
SELECT @JSON=BulkColumn
FROM OPENROWSET (BULK '/var/opt/mssql/RC_2015-01.json', SINGLE_CLOB) import
SELECT *
FROM OPENJSON (@JSON)
pundip
  • 27
  • 5