I want to read a text (in this case, csv) from a file. I'm not trying to bulk-load for now, simply read.
As far as I can tell, only the SQLNCLI provider is available.
Ad Hoc Distributed Queries are enabled (value_in_use = 1 for
select * from sys.configurations where name like '%ad hoc Dis%'
)
SELECT * FROM OPENROWSET('SQLNCLI',
'server=localhost;trusted_connection=yes;
Driver={Microsoft Text Driver (*.txt; *.csv)};
data source=\\valid\path\to\my\folder\Test.csv;
Extensions=csv;HDR=yes;FMT=Delimited',
'SELECT * FROM [Test.csv]'
) AS data;
I get this error:
>OLE DB provider "SQLNCLI11" for linked server "(null)" returned message "Deferred prepare could not be completed.".
>
>Invalid object name 'Test.csv'.
What am I doing wrong? Is [Test.csv] the right way to reference the file?
Using:
Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0 (X64) Mar 18 2018 09:11:49 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
Asked by alazyworkaholic
(111 rep)
Apr 14, 2023, 09:45 PM
Last activity: Apr 18, 2023, 12:28 PM
Last activity: Apr 18, 2023, 12:28 PM