Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MS-SQL CLR reads and writes files directly. It feels like flying.

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Write a CLR extension DLL, in SQL directly read and write file extension function. Read data variables directly to a file.

The program was written in VS2010, in Vb.net.

There are four scalar functions:

GetFile_Str16(@PathFile NVARCHAR(max))--Return: NVARCHAR(max) --Read [file] into [hexadecimal numeric text]

PutFile_Str16(@PathFile NVARCHAR(max),@Str16 NVARCHAR(max))--Returns: Bit --Generate [file] with [hexadecimal numeric text]

GetFile_Binary(@PathFile NVARCHAR(max))--Return: VarBinary(Max) --Read [File] to [VarBinary]

PutFile_Binary(@PathFile NVARCHAR(max),@Bin VarBinary(Max))--Returns: Bit --Generate [File] with [VarBinary]

Yeah! To prevent the target file from being opened (locked) by other programs during reading, resulting in reading failure.

GetFile_Str16, GetFile_Binary, when the target file is locked, it will try to copy the target file to create a copy for reading.

Attachments include DLL files, VB.net source code, install (deploy) T-SQL scripts, uninstall T-SQL scripts, test T-SQL scripts.

and: stored procedure [FileToBin], which implements GetFile_Binary function in stored procedure mode.

Attachment: down.51cto.com/data/2367601

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report