Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-06-01 10:06:46 10月23日 Update

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

Tags: Files data targets scripts binaries functions numbers text programs procedures binaries attachments storage generation copies functions variables situations methods scalars Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei OPPO Reno Shulou Tech Info NVidia