如何使用SSIS指定变量文件名?

时间:2021-07-27 02:58:41

I'm a newbie to using SSIS for data imports - I have a couple of files that I want to import into my database schema, but I'm going to need to run this once every 3 months; the file names change based on the quarter e.g. SKU1QTR will become SKU2QTR.

我是使用SSIS进行数据导入的新手 - 我有几个文件要导入到我的数据库模式中,但是我需要每3个月运行一次;文件名根据季度变化,例如SKU1QTR将成为SKU2QTR。

How can I handle a situation like this with SSIS? Is there a way to specify the file names (there are at least 6 files like this) or, better yet, just specify the numeric portion since the rest of the file always stays the same?

我如何使用SSIS处理这种情况?有没有办法指定文件名(至少有6个这样的文件),或者更好的是,只需指定数字部分,因为文件的其余部分始终保持不变?

2 个解决方案

#1


Create a script task and do something like this, where FlatFileCSV would be the name of your connection

创建一个脚本任务并执行类似这样的操作,其中FlatFileCSV将是您的连接的名称

Dts.Connections("FlatFileCSV").ConnectionString = 
"E:\SomeFile" + theDate.ToString("yyyyMMdd") + ".csv"

#2


Put your filename/connection string in a configuration file. If that truly is the only thing that is different, then you can even run the package from command line and you won't need to open BIDS at all.

将您的文件名/连接字符串放在配置文件中。如果真的是唯一不同的东西,那么你甚至可以从命令行运行包,你根本不需要打开BIDS。

As you are a self described newbie, this is a bit more advanced, but it is a technique worth knowing.

由于你是一个自我描述的新手,这有点先进,但这是一项值得了解的技术。

#1


Create a script task and do something like this, where FlatFileCSV would be the name of your connection

创建一个脚本任务并执行类似这样的操作,其中FlatFileCSV将是您的连接的名称

Dts.Connections("FlatFileCSV").ConnectionString = 
"E:\SomeFile" + theDate.ToString("yyyyMMdd") + ".csv"

#2


Put your filename/connection string in a configuration file. If that truly is the only thing that is different, then you can even run the package from command line and you won't need to open BIDS at all.

将您的文件名/连接字符串放在配置文件中。如果真的是唯一不同的东西,那么你甚至可以从命令行运行包,你根本不需要打开BIDS。

As you are a self described newbie, this is a bit more advanced, but it is a technique worth knowing.

由于你是一个自我描述的新手,这有点先进,但这是一项值得了解的技术。