FileRead
Reads Text or Binary data from a file
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.FileRead @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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
DECLARE @FilePath varchar(MAX) DECLARE @Encoding varchar(100) DECLARE @FileContent nvarchar(MAX) --Assign a path to a file that the executing user has read permissions on SET @FilePath = 'C:\ThisFolderExists\ThisFileExists.txt' SET @Encoding = 'ASCII' --Encoding can also be a numeric code page EXEC SQLHTTP.net.FileRead @FilePath, @Encoding, @FileContent OUTPUT SELECT @FileContent |
1 2 3 4 5 |
------------------------------------------------- This is the content of the ThisFileExists.txt |
- CodePageEncodings
- FileCopy
- FileDecrypt
- FileDelete
- FileEncrypt
- FileMove
- FileRead
- Files_To_Table
- FileWrite
- FolderCopy
- FolderCreate
- FolderDelete
- FolderMove
- Folders_To_Table
- GlobalTable_To_File
- IsExistingFile
- IsExistingFolder
- TempPath
- ZipEntryAppend
- ZipEntryRemove
- ZipExtract_To_Folder
- ZipExtract_To_Table