[英]Where to store CSV file in SSIS file within SQL Server
I have a SSIS task in which the control flow pulls data from an external source, uploads it to CSV and modifies the rows, and then uploads the CSV file into a SQL server table. 我有一个SSIS任务,其中控制流从外部源中提取数据,将其上传到CSV并修改行,然后将CSV文件上传到SQL Server表中。
Normally I'd keep the CSV local file on my machine and reference it there, but when deploying the SSIS package to SQL Server to run as a scheduled job that becomes no longer feasible. 通常,我会将CSV本地文件保留在我的计算机上,并在那里引用它,但是当将SSIS包部署到SQL Server以作为计划的作业运行时,这不再可行。 Additionally, I cannot create a temporary table within the SQL server as a substitute for the CSV file in this specific scenario.
此外,在这种特定情况下,我无法在SQL Server中创建一个临时表来替代CSV文件。
Is it possible to upload a CSV file as a CSV within a SQL server? 是否可以在SQL Server中将CSV文件上传为CSV文件? Alternatively, what is the best way to reference an externally stored CSV file or otherwise substitute a temporary CSV file within the SSIS package such as a temporary flat file?
或者,什么是引用外部存储的CSV文件或以其他方式替换SSIS包中的临时CSV文件(例如临时平面文件)的最佳方法?
There are several ways to achieve this. 有几种方法可以实现此目的。 One way would be to save it on a network drive and use openrowset, openquery depending on the type of driver you have installed in the SQL server to access the csv file like a table.
一种方法是将其保存在网络驱动器上,并根据您在SQL Server中安装的驱动程序类型使用openrowset,openquery来访问csv文件(如表)。
see examples: 看例子:
SELECT *
FROM
OpenRowset('MSDASQL','Driver={Microsoft Access Text Driver (*.txt, *.csv)};
Extended properties=''ColNameHeader=True;
Format=Delimited;''',
'select * from \\server1\File.csv'
)Bas
OR 要么
SELECT
*
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'Text;Database=D:\NetworkLocation\;HDR=Yes;FORMAT=Delimited(;)',
'SELECT * FROM [File.csv]') i
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.