对于SQL Server 2008,我有一个接受VarBinary参数的存储过程。当参数在内存中时,我想将它写入SQL Server的%temp%目录。内存VarBinary中的TSQL到文本文件?
如何从内存blob(它来自一个C#应用程序的字节[])到文本文件?该blob不存在于任何磁盘驻留表中。
我倾向于让TSQL存储过程调用一个CLR存储过程,目前看起来(大部分)如下所示。
问题#1是我认为inputBytes []卡在8k输入大小。
问题#2是我似乎无法想出一些体面的SQL,将varbinary值作为参数传递,因此我可以在Management Studio或VS DB单元测试中测试此值。
public static void FileWrite(string inputName , byte[] inputBytes)
using (FileStream fileStream = new
FileStream(Environment.GetEnvironmentVariable("TEMP") + "\\" + inputName,
FileMode.OpenOrCreate, FileAccess.Write))
{
using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
{
binaryWriter.Write(inputBytes);
}
}
谢谢。
谢谢你,当你指着我指向CLR sproc时,我自己正在走这条路。我似乎无法弄清楚如何将一个无限大小的VarBinary(Max)并将它作为byte []发送给CLR sproc,以便我可以编写它....时间来编辑我的原始帖子。谢谢。 – Snowy 2011-01-12 04:15:31