Saves text or binary data to a file

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


EXEC @FilePath, @Content, @Encoding


Name Type Description
@FilePath varchar(MAX) Full path to a new file
@Content nvarchar(MAX) Content to be saved. Binary data should first be converted to Base64 encoding
@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


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: