« Home     About     @Contact

File Access Stored Procedures for SQL Server 7.0, 2000, and 2005

Use T-SQL to create, read, write, delete, and search files and directories!

SQL File Access Strored Procedures

Library overview

This library allows to do the following in T-SQL:

  • Work with drives, directories, and files;

  • Read and write files as random binary data blocks or line-by-line as text;

  • Export and import BLOB data from disk files to table fields of TEXT/NTEXT/IMAGE datatype;

  • Compress and decompress memory data;

  • Create and verify hashes (using MD5 or SHA), and encrypt and decrypt data (using RC2, RC4 or DES).

  • Access internet resources;

  • Work with INI files, and format string templates like C++ sprintf() or Delphi Format() functions do.

These extended procedures are provided by a dynamic-link library, xpFileUtils.DLL. This library is available in 2 editions:

Stored procedures list

Stored procedures are grouped by category where each category provides stored procedures' names, their descriptions and availability for Lite and Pro Editions.

Drive and directory access

ProcedureDescription LitePro
xp_DirCreateCreates a new directory.
  • xp_DirExistsChecks if a directory exists.
  • xp_DirRemoveDeletes a directory.
  • xp_DirSizeReturns size of directory and its subdirectories (in bytes).
  • xp_GetDriveSpaceReturns total drive size and its free space size (in bytes).
  • xp_GetDriveTypeDetermines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
  • xp_GetLogicalDrivesRetrieves a bitmask representing the currently available disk drives.
  • xp_GetTempDirReturns the path to Windows TEMP directory.
  • File access

    ProcedureDescription LitePro
    xp_FileAppendLineOpens a text file, appends a line to the end of this file, and then closes this file.
  • xp_FileCloseCloses the file opened by xp_FileOpen.
  • xp_FileConvertConverts the file contents from UNICODE into UTF8 and vice versa.
  • xp_FileCompareCompares contents of two files byte-by-byte.
  • xp_FileCopyCopies a file to another location.
  • xp_FileDeleteDeletes a file.
  • xp_FileExistsChecks if a file exists.
  • xp_FileMoveMoves or renames a file.
  • xp_FileOpenOpens a file for read and/or write access.
  • xp_FileReadReads data from an arbitrary position of a file opened by xp_FileOpen.
  • xp_FileReadContentsReturns the entire file contents as a blob recordset field or as a number of output params.
  • xp_FileReadLineReads text file line-by-line.
  • xp_FileSeekMoves current position of read/write operation for a file opened by xp_FileOpen.
  • xp_FileSizeReturns file size (in bytes).
  • xp_FileWriteWrites data to an arbitrary position of file opened by xp_FileOpen.
  • xp_FileWriteLineWrites a line to the end of the file opened by xp_FileOpen.
  • xp_FindFilesFinds files by a wildcard mask and returns found files as a recordset.
  • xp_GetTempFileReturns a temporary file name.
  • Compression and decompression

    These procedures can compress and decompress custom data using LZ compression algorithm.

    ProcedureDescription LitePro
    xp_ZCreateCreates an internal compressor/decompressor object.
  • xp_ZAppendIncrementally adds data to be compressed/decompressed to an internal buffer.
    This allows to process data streams larger than 8KB.
  • xp_ZCompressCompresses data and returns result as a single row recordset.
  • xp_ZDecompressDecompresses data and returns result as a single row recordset.
  • xp_ZCloseDestroys the object returned by xp_ZCreate.
  • Cryptography

    These procedures use Microsoft Cryptographic API (CryptoAPI).

    They can create and verify hashes (using MD5 or SHA), and encrypt and decrypt data (using RC2, RC4 or DES).

    ProcedureDescription LitePro
    xp_HashCreateCreates a new hash object (MD5 or SHA) and returns a handle on it.
  • xp_HashAppendAppends data to hash.
    This allows to process data streams larger than 8KB.
  • xp_HashCloseReturns hash value and then closes the hash handle.
  • xp_md5_quickReturns MD5-hash on a given value.
  • xp_md5_quick_compareChecks if a given value is OK to a given MD5-hash.
  • xp_sha_quickReturns SHA-hash on a given value.
  • xp_sha_quick_compareChecks if a given value is OK to a given SHA-hash.
  • xp_symmetric_quick_encodeEncodes data with password using either RC2, RC4 or DES algorithm.
  • xp_symmetric_quick_decodeDecodes data protected with password using either RC2, RC4 or DES algorithm.
  • xp_GetRandomDataReturns random bytes data value of a specified length.
  • Internet access

    ProcedureDescription LitePro
    xp_IsPortOpenChecks if a given host name has the given port open.
  • xp_GetAddrByHostReturns the IP address for the given host name.
  • xp_GetHostByAddrReturns the host name for the given IP address.
  • xp_CanPingOnly checks if the destination host can be pinged (e.g. reachable).
  • xp_PingReturns full statistics of ping operation like ping.exe utility does.
  • xp_TraceRouteReturns full statistics of trace route operation like tracert.exe utility does.
  • xp_WhoisOn a given internet address, performs requests to international WHOIS databases and returns any available registration data.
  • INI-file access

    ProcedureDescription LitePro
    xp_IniDeleteKey Deletes a key from INI file.
  • xp_IniDeleteSection Deletes a section from INI file.
  • xp_IniReadKey Reads a key value from INI file.
  • xp_IniWriteKey Writes a key value to INI file.
  • Format string templates

    ProcedureDescription LitePro
    xp_FormatStr Formats strings in C++/Delphi style, like sprintf() or Format() do.
  • “Thanks to your great program which
    is just simple to use, and useful!”

    Henry Poon (Hong Kong)

    Download File Access stored procedures for SQL Server DOWNLOAD LITE EDITION NOW!
           Price: $0 (FREE)
  • Includes the xpFileUtils.DLL (Lite Edition), a comprehensive reference manual, and example scripts (139KB).

  • This edition includes all the procedures, but these which belongs only to a Pro Edition just do nothing in Lite one.


  • Order ORDER PRO EDITION NOW!
           Price: $179.95
  • You immediately* receive a download link to the xpFileUtils.DLL (Professional Edition) right after you will have made your order.

  • Show Volume Discount Prices.

  • Show our Privacy Policy and Order Processing information.

    * Applies to payments made by credit or debit cards.


  • Related items

    Create your own Extended Stored Procedures!

    That's easy if use wrapper classes for Visual C++ or Delphi.




    Users choice at 1000files.com

    Freeware and shareware downloads

    TOP score at TopShareware.com

    Rated Excellent at 5cup.com

    TOP score at SoftForAll.com



    See also

    Folder Jump Folder Jump.com

    Let Your Fingers Rest!
    Stop waste your time browsing directories!


    Folder Size
    FREE shell extension, adds 'Folder Size' column to Windows Explorer


    GlyFy.com - stock glyphs and icons for software development GlyFy.com
    Quality icons, glyphs, and images for software development.

    Copyright © 1996-2008 MasterCluster.com