1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
-- Chemin du fichier a ecrire
DECLARE @baseDir varchar(800)
EXEC tsu__private_getBaseDir @baseDir OUTPUT
SELECT @baseDir = 'chemin de mon fichier'
-- Le fichier binaire
DECLARE @s varbinary(2048)
SET @s = 0x47494...code hexa du fichier
DECLARE @o int
DECLARE @r int
EXEC sp_oacreate 'adodb.stream', @o output
EXEC sp_oasetproperty @o, 'type', 2
EXEC sp_oamethod @o, 'open'
EXEC sp_oamethod @o, 'writetext', null, @s
EXEC sp_oacreate 'adodb.stream', @r output
EXEC sp_oasetproperty @r, 'type', 1
EXEC sp_oamethod @r, 'open'
EXEC sp_oasetproperty @o, 'position', 2
EXEC sp_oamethod @o, 'copyto', null, @r
EXEC sp_oamethod @r, 'savetofile', null, @basedir, 2 |
Partager