Bulk importing to SQL Server from a remote data file using UNC paths

213 Views Asked by At

As mentioned on the MSDN for bulk import, I tried to use UNC path for importing data but it fails.

SELECT
    '\\FS1-CBR.strange.ibm.au\{fu-spec}\work\Proj1 Vis-NIR_all\New South Wales\file1.asd',
    * FROM OPENROWSET(BULK N'\\FS1-CBR.strange.ibm.au\{fu-spec}\work\Proj1 Vis-NIR_all\New South Wales\file1.asd', SINGLE_BLOB) AS FileData

It fails with error:

Cannot bulk load because the file "\FS1-CBR.strange.ibm.au{fu-spec}\work\Proj1 Vis-NIR_all\New South Wales\file1.asd" could not be opened. Operating system error code 5(Access is denied.).

I guess it is failing due to the substring {fu-spec} in the UNC path. I can access the file through file explorer as well as programmatically as I have the permissions to this location.

How to import the file in this case using OPENROWSET BULK in SQL Server?

0

There are 0 best solutions below