I have to do it:
- Take this @HTML and save the file
example.txt example.txtsave .zipwith password.zip convert file to blob and save to table
Do you know how to do this only in T-SQL? Is it possible?
DECLARE @HTML varchar(200)
SET @HTML = '<html>
<META http-equiv=Content-Language content=pl>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<body style="color:black; font-family: verdana, arial, helvetica, sans-serif; font-size:11px;">
TEST</body></html>'
SELECT @HTML
Using something like this?
EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
EXEC sp_OASetProperty @ObjectToken, 'Type', 1
EXEC sp_OAMethod @ObjectToken, 'Open'
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @IMG_PATH
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @TIMESTAMP, 2
EXEC sp_OAMethod @ObjectToken, 'Close'
EXEC sp_OADestroy @ObjectToken
OK I created this:
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
namespace SaveBlobData
{
class SaveHTML
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void SaveBlob(out SqlInt32 value, int idZak)
{
value = 3 + idZak;
}
}
}
I add .dll, but I get an error when choosing this. Where is the problem?

source
share