SSIS:动态连接字符串上不需要的行 return
SSIS : Unwanted line return on a dynamic connection string
在 SSIS 包中,我想将数据从多个实例发送到一个平面文件。为此,我创建了一个由 3 个变量组成的动态连接字符串:
- ".txt"
- 网络路径
- 文件名(这是我在包中其他地方使用的实例名称变量(字符串))
当我此时评估我的表达时,我收到:
为
TRIM(@[User::FileName]+REPLACE(@[User::ServerName],"\","")+@[User::ExtensionFile])
我收到
\test-01\TEMP\SQL01MyInstance.txt
但是,当我 运行 作业时,它无法创建 SQL01MyInstance.txt,我收到错误消息:
[Flat File Destination [11]] Error: Cannot open the datafile "\test-01\TEMP\SQL01MyInstance
.txt".
[SSIS.Pipeline] Error: Flat File Destination failed the pre-execute phase and returned error code 0xC020200E.
文件名末尾有不需要的 space,当我将错误消息复制粘贴到别处时,它似乎是一行 return(在 .txt 之前)
有谁知道我怎样才能摆脱那一行 return(我假设这会使工作失败)?
编辑 1:
目标文件夹的权限没问题,因为我创建了另一个平面文件以防出错,并且在失败后正常创建;但不是动态名称(正常行为)
TRIM 函数仅 trim 是 space 字符(相对于 trim 全白 space 的其他函数):
TRIM does not remove white-space characters such as the tab or line feed characters. Unicode provides code points for many different types of spaces, but this function recognizes only the Unicode code point 0x0020. When double-byte character set (DBCS) strings are converted to Unicode they may include space characters other than 0x0020 and the function cannot remove such spaces. To remove all kinds of spaces, you can use the Microsoft Visual Basic .NET Trim method in a script run from the Script component.
https://docs.microsoft.com/en-us/sql/integration-services/expressions/trim-ssis-expression
您可以先试试看是否有效(Trim 先连接再连接):
TRIM(@[User::FileName]) + TRIM(REPLACE(@[User::ServerName],"\","")) + TRIM(@[User::ExtensionFile]))
如果不是,则您必须使用 MSDN 文章推荐的脚本 Task/Component 执行推荐的 String.Trim() 函数(同样,首先 Trim 每个变量,然后连接)
要删除第 return 行,您可以将 REPLACE()
函数与 \r\n
一起使用
REPLACE(REPLACE(TRIM(@[User::FileName]+REPLACE(@[User::ServerName],"\","")+@[User::ExtensionFile]),"\r",""),"\n","")
在哪里
\r : carriadge return
\n : line feed
在 SSIS 包中,我想将数据从多个实例发送到一个平面文件。为此,我创建了一个由 3 个变量组成的动态连接字符串:
- ".txt"
- 网络路径
- 文件名(这是我在包中其他地方使用的实例名称变量(字符串))
当我此时评估我的表达时,我收到:
为
TRIM(@[User::FileName]+REPLACE(@[User::ServerName],"\","")+@[User::ExtensionFile])
我收到
\test-01\TEMP\SQL01MyInstance.txt
但是,当我 运行 作业时,它无法创建 SQL01MyInstance.txt,我收到错误消息:
[Flat File Destination [11]] Error: Cannot open the datafile "\test-01\TEMP\SQL01MyInstance
.txt".[SSIS.Pipeline] Error: Flat File Destination failed the pre-execute phase and returned error code 0xC020200E.
文件名末尾有不需要的 space,当我将错误消息复制粘贴到别处时,它似乎是一行 return(在 .txt 之前)
有谁知道我怎样才能摆脱那一行 return(我假设这会使工作失败)?
编辑 1:
目标文件夹的权限没问题,因为我创建了另一个平面文件以防出错,并且在失败后正常创建;但不是动态名称(正常行为)
TRIM 函数仅 trim 是 space 字符(相对于 trim 全白 space 的其他函数):
TRIM does not remove white-space characters such as the tab or line feed characters. Unicode provides code points for many different types of spaces, but this function recognizes only the Unicode code point 0x0020. When double-byte character set (DBCS) strings are converted to Unicode they may include space characters other than 0x0020 and the function cannot remove such spaces. To remove all kinds of spaces, you can use the Microsoft Visual Basic .NET Trim method in a script run from the Script component.
https://docs.microsoft.com/en-us/sql/integration-services/expressions/trim-ssis-expression
您可以先试试看是否有效(Trim 先连接再连接):
TRIM(@[User::FileName]) + TRIM(REPLACE(@[User::ServerName],"\","")) + TRIM(@[User::ExtensionFile]))
如果不是,则您必须使用 MSDN 文章推荐的脚本 Task/Component 执行推荐的 String.Trim() 函数(同样,首先 Trim 每个变量,然后连接)
要删除第 return 行,您可以将 REPLACE()
函数与 \r\n
REPLACE(REPLACE(TRIM(@[User::FileName]+REPLACE(@[User::ServerName],"\","")+@[User::ExtensionFile]),"\r",""),"\n","")
在哪里
\r : carriadge return
\n : line feed