我已使用DBAMP salesforce数据集成工具将附件从salesforce下载到sql server。
但实际附件在IMAGE dataype列中存储为二进制字节。
我正在尝试将图像中的数据导出到文件但到目前为止还没有成功 使用下面的SQL CLR函数和varbinary值的例子转换为test.jpg。有人请帮忙
0xFFD8FFE000104A46494600010200006400640000FFEC00114475636B7900010004000000500000FFEE002641646F62650064C0000000010300150403060A0D00000236000002E10000039F00000494FFDB0084000202020202020202020203020202030403020203040504040404040506050505050505060607070807070609090A0A09090C0C0C0C0C0C0C0C0C0C0C0C0C0C0C01030303050405090606090D0B090B0D0F0E0E0E0E0F0F0C0C0C0C0C0F0F0C0C0C0C0C0C0F0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0CFFC20011080016001903011100021101031101FFC400B300010101000000000000000000000000000607050101010101000000000000000000000000050403061000010303020505000000000000000000010203040010051112214132131422233415061100020102040502070000000000000000010203110400213112104132131422058292B223337315120002020301000000000000000000000000011011213102A113010002010400060301000000000000000111210010314151F0618191A1C171D1F1E1FFDA000C030100021103110000015BDEF17B93ED9FB662933F5E2AEEBCEB9197C6317C290F42AC329237083F6C7FFFDA0008010100010502932A435231917319632D125A353BE6FE77C0FA35F8DBAA534DAE4605B 427081086D8AFFFDA00080102000105024A010EADB6E9B20D9BE993BBB89D6C93C241F735D4D7FFDA000801030001050252882DA56E52C1165F547DBDB3A59438B03D1CABFFDA0008010202063F02B3284D42178737B8D1C8A3FFDA0008010302063F0230C69C318EA7A1C7FFDA0008010101063F029A18A778A385CA22231514534E5897C6BC755869BDE495C0CF9655C5FD9DE4DE43DAAAB07DC5A87720C89CF46E177FBA4FA8E2FBF2743FF47E53D3F0E3DCFC4DDE376876B7F553B91EBC26737290BB3B192270F556AE63D2AC35C7BE01708E1A37AB8DF41F6CEB5518BAD9289D99006D9501577AE7EA0BCE9C3FFFDA0008010103013F212F5DF020523AC2204B219C0B16BAC1711CE56A521B9A2C6148687988F05E78E9CF8B937D11D44E255CC04A11C8C3627B34A7B0E547FEA63A962C0403BE9FFFDA0008010203013F212A815C89E4E8320BC4FA70FEB4F80675DC7F5EB9EAAFA7470927DBEE319ADDCEBBFCE0A511FC7A9D3FFFDA0008010303013F21600C064F7079E49398FF003F7A7C873EC3FCF4CFC5C7D9A02AE3DFEB00BBC462044CFF004EF4FFDA000C030100021103110000104E56F30A6FFFDA0008010103013F10AD573F3CE1524ADADB90C48356D25C135022D249212F8595861282024DAB24EDF6D0682804D150CBF5617B50B061BE1CB2727CDC4D6E26C2BEC2C4C00 901614605426789E758291E2F64B604EE8580CBCFFFDA00080102
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
using Microsoft.SqlServer.Server;
using System.Text;
namespace BlobExport
{
public class Functions
{
[SqlFunction]
public static SqlString WriteToFile(SqlBytes binary, SqlString path)
{
try
{
byte[] byteArr = binary.Value;
string filepath = path.Value;
File.WriteAllBytes(filepath, byteArr);
return "SUCCESS";
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}