I'm having difficulty accessing data in a text file via OPENROWSET. The file is saved locally. I'm raising the error which seems to be related to the location of the file but I'm really confused as to why SQL Server cant find it.
Msg 12704, Level 16, State 1, Line 3 Bad or inaccessible location specified in external data source "(null)".
I'm using UNC naming convention. And I've double checked the file name & location are in fact correct & the file does contain data.
Can anyone please help me correct this T-SQL so that I can access the file via OPENROWSET?
DECLARE @json_data VARCHAR(MAX)
SELECT @json_data = BulkColumn FROM OPENROWSET(BULK'\\LAPTOP-14K308TA\C$\Users\EB\Desktop\Python Files\comp_data.json', SINGLE_BLOB) JSON;
SELECT @json_data as SingleRow_Column
IF (ISJSON(@json_data) = 1)
BEGIN
PRINT 'Imported JSON is valid'
END
ELSE
BEGIN
PRINT 'Invalid JSON imported'
END
GO
Turns out the file location was incorrect, fixing the file location solved the problem.