当前位置:网站首页>SQL server saves binary fields to disk file

SQL server saves binary fields to disk file

2022-06-25 11:44:00 VFP of Garfield

Fox friends social science heroes shared a piece of code , Binary fields can be saved to disk files .

--open
GO
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'Ole Automation Procedures', 1
RECONFIGURE
GO
EXEC sp_configure 'Ole Automation Procedures'

DECLARE @DATA VARBINARY(MAX)
DECLARE @ObjectToken INT
DECLARE @TIMESTAMP VARCHAR(MAX)

SET @TIMESTAMP = 'd:\abc.png'

EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
EXEC sp_OASetProperty @ObjectToken, 'Type', 1
EXEC sp_OAMethod @ObjectToken, 'Open'
EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @DATA
EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @TIMESTAMP, 2
EXEC sp_OAMethod @ObjectToken, 'Close'
EXEC sp_OADestroy @ObjectToken

SELECT @TIMESTAMP

--close
GO
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'Ole Automation Procedures', 0
RECONFIGURE
GO
EXEC sp_configure 'Ole Automation Procedures'
GO
sp_configure 'show advanced options', 0
RECONFIGURE

Of course ,myfll author : Papaya , Brother Gua also wrote a set dll, Coping with MSSQLSERVER Manage the of files DLL,
At the request of guage , Only for appreciation .

File management function

Heroes in the community , many master-hands . The expert filled up all the pits , You can drive on the highway .

The fastest way for people to grow

  1. Is to practice Kung Fu with experts .

  2. The core outline of practice is daily work .

  3. Daily work is : See a piece of good code every day , Try copying a piece of code .

Garfield graduated from hosting and speaking five years ago , This can present a better course .

a new year , We will work together .

原网站

版权声明
本文为[VFP of Garfield]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200535523124.html