简体   繁体   English

在SQL Server的SSIS文件中的哪里存储CSV文件

[英]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.

相关问题 CSV文件通过SSIS导入SQL服务器 - CSV file import into SQL Server through SSIS 从csv文件到SQL Server日期时间的SSIS Unix时间戳 - SSIS Unix timestamp to SQL Server datetime from csv file 使用SSIS将CSV文件导入到SQL Server表 - Importing CSV file to a SQL Server table using SSIS SQL Server在哪里存储SSIS包? - Where does SQL Server store the SSIS packages? 如何将 sql 服务器查询结果导出到 .csv 文件,数据在导出文件中应使用双引号 SSIS - How to export the sql server query result to .csv file and data should be double quotes in exported file using SSIS 在Ruby中读取包含特殊字符的CSV文件并存储到SQL Server中 - Read a CSV file with special characters in Ruby and store into SQL Server 无法通过SSIS将括号中的数字转换为CSV文件中的负数作为SQL数据库 - failing to convert numbers in parenthesis within a CSV file, to a SQL database as negative numbers, via SSIS 将 CSV 文件插入到 SQL 服务器中已有的表中 - Insert CSV file to already existing table within SQL Server SSIS:日期格式向SQL Server表发出csv文件:DD和MM交换 - SSIS: Date format Issue csv file to a SQL Server table: DD and MM swapped SSIS使用.CSV文件SQL Server 2005中的参数执行存储过程 - SSIS Execute a Stored Procedure with the parameters from .CSV file SQL Server 2005
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM