READ_FILE_TEXT
Function
Reads the contents of a text file and returns it as a single string representing the whole file.
Syntax
READ_FILE_TEXT(file-path, [file-encoding])
Parameters
- file-path: text
The absolute path to the text file to read. -
file-encoding: integer (optional, 0-65535, default: 0)
Indicates the text encoding to use when reading the file. Specify 0 to detect the encoding automatically. Any nonzero integer is treated as a Windows code page number. See Character Encodings in CSV and Text Files for a list of these code page numbers.
Return Value
Contents of the file as a text string.
Example
-- Auto-detected Unicode file encoding.
PRINT READ_FILE_TEXT('C:\MyFile.txt');
-- Produces a 1-row query result with file contents read
-- using the Japanese Shift-JIS encoding (code page 932).
SELECT READ_FILE_TEXT('C:\ShiftJIS.txt', 932) AS data;