Reads Text or Binary data from a file

  • Stored Procedure
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017


EXEC @FilePath, @Encoding, @FileContent OUTPUT


Name Type Description
@FilePath varchar(MAX) Full path to the file
@Encoding varchar(20) Can be of the following: ASCII, BASE64, UNICODE, UTF7, UTF8, UTF32, or any other Code Page or Encoding Name available in the following View: CodePageEncodings. Use BASE64 for all Binary data
@FileContent nvarchar(MAX) Output Parameter. Content to be read from file. Remember to convert BASE64 output to Binary or even to String data, if necessary.


Accessing the file system will be performed in the context of the SQL Server instance process. You can set SQL Server to run using a specific network account, or a Local System Account.

Sample Usage:

See Also: