SSIS 将字符串变量保存到文本文件 [英] SSIS save string variable to text file

查看:33
本文介绍了SSIS 将字符串变量保存到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来应该很简单,但到目前为止我还没有找到一种方法来将存储在 SSIS 字符串变量中的值保存到文本文件中.我曾考虑在数据流中使用平面文件目标,但这需要数据流源.

It seems like it should be simple but as of yet I havent found a way to save the value stored in an SSIS string variable to a text file. I've looked at using the flat file destination inside of a data flow but that requires a data flow source.

关于如何做到这一点的任何想法?

Any ideas on how to do this?

推荐答案

这里是一些在 C# 中的 SQL CLR 中工作的代码的小示例.如果你在 2005 年,我相信你需要使用 VB.脚本任务还需要将 read 变量属性设置为 MyVariable 以使您的变量值可供它使用.

Here's a little sample of some code that worked in a SQL CLR in C#. You'll need to use VB if you're on 2005 I believe. The script task also needs the read variable property set to MyVariable to make the value of your variable available to it.

// create a writer and open the file

TextWriter tw = new StreamWriter("\\\\server\\share$\\myfile.txt");

// write a line of text to the file

tw.WriteLine(Dts.Variables["MyVariable"].Value);

// close the stream
tw.Close();

这篇关于SSIS 将字符串变量保存到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆