MS-SQL CLR reads and writes files directly. It feels like flying.
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