using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.IO;

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlBytes CompressBytes(SqlBytes UnCompressedBytes, byte CompressMethod)
{
try
{
MemoryStream output = new MemoryStream();
SqlFuncCompression.CompressWrapper.Compress(new
MemoryStream(UnCompressedBytes.Value), output,
((SqlFuncCompression.eCompressMethod)(CompressMethod)));
return new SqlBytes(output.ToArray());
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}

[Microsoft.SqlServer.Server.SqlFunction]
public static SqlBytes DeCompressBytes(SqlBytes CompressedBytes, byte CompressMethod)
{
try
{
MemoryStream output = new MemoryStream();
SqlFuncCompression.CompressWrapper.Decompress(new
MemoryStream(CompressedBytes.Value), output,
((SqlFuncCompression.eCompressMethod)(CompressMethod)));
return new SqlBytes(output.ToArray());
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
};

Поделитесь материалом с коллегами и друзьями