Contact   About
Apps for Windows Source Code SQL Server Extensions  

File Access Stored Procedures for SQL Server 7.0, 2000, 2005 and later (Win32)

Library overview (version

Use file system from T-SQL and do even more:

  • Direct file system access:
    • Work with disk drives, directories, and files;
    • Read and write files (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;
    • Work with INI files;
  • Compress and decompress memory data;
  • Create and verify MD5 or SHA hashes;
  • Encrypt and decrypt data (using RC2, RC4, or DES);
  • Access resources in the internet;
  • Format string templates (like C++ sprintf or Delphi Format functions do).

This extended stored procedures library works with SQL Server 6.5, 7.0, 2000, 2005, and later. The library is a native Win32 DLL and thus can run only on a 32 bit SQL Server.

The library is available in 2 editions:

The Standard and Professional editions include all the procedures (listed below), but only the Professional edition implements all the procedures. For example, it is possible to call xp_DirCreate, but this procedure immediately exits in the Standard edition.
SQL File Access Strored Procedures

Get It Here!

  1. Download FREE Standard Edition (500K download size) including sample scripts and a comprehensive reference manual in CHM format.
  2. Read our Privacy Policy and Order Processing information.
  3. Buy the Professional Edition using a safe payment processing service from Share*it!. Volume discount prices available.

Stored procedures list

The extended stored procedures are grouped by category where each category provides stored procedures' names, their descriptions and availability in Std and Pro Editions.

Drive and directory access

ProcedureDescription StdPro
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 StdPro
    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 StdPro
    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 StdPro
    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 StdPro
    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 StdPro
    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 StdPro
    xp_FormatStr Formats strings in C++/Delphi style, like sprintf() or Format() do.

  • Related Documents

    File Access Stored Procedures for SQL Server 2005 and later (.NET)
    Delphi extended stored procedure component for SQL Server 7.0, 2000, 2005
    C++ Extended stored procedure class for SQL Server 7.0, 2000, 2005
    Copyright © 2003-2017
    Share |