从数据库表导出到CSV文件

我正在尝试使用以下脚本将数据从数据库表导出到CSV文件:

USE DATABASE;

INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Text;Database=C:\TEMP\;HDR=YES;FMT=CSVDelimited',
'SELECT * FROM [CSV_TEST.csv]')
SELECT [ColumnA]
      ,[ColumnB]
      ,[ColumnC]
FROM dbo.CSV_TEST;

CSV文件位于数据库服务器上的C:\ TEMP目录下,并且文件名和列与CSV_TEST表完全相同。运行查询时,出现以下错误。如果您有解决方法的想法,那就太好了!提前谢谢了...

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Cannot update. Database or object is read-only.".
Msg 7399, Level 16, State 1, Line 3
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider indicates that the user did not have the permission to perform the operation.
Msg 7343, Level 16, State 2, Line 3
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" could not INSERT INTO table "[Microsoft.ACE.OLEDB.12.0]". 
评论