FTP_FileRead
Reads the content of a file on a remote FTP Server
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.FTP_FileRead @URL, [@UserName], [@Password], @FileEncoding, @FileContent, [@StatusCode], [@StatusDescription]
Name | Type | Description |
---|---|---|
@URL | nvarchar(4000) | Required. FTP address that includes the source file name.
|
@UserName | nvarchar(200) | Optional. Leave blank (NULL) for anonymous connections
|
@Password | nvarchar(200) | Optional. Leave blank (NULL) for anonymous connections
|
@FileEncoding | varchar(100) | Required. 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) | Read Only. Output Parameter. File content data received from the remote FTP server. Binary data is returned as a Base64 string.
|
@StatusCode | int | Optional. Output Parameter. Numeric status of the response.
|
@StatusDescription | nvarchar(MAX) | Optional. Output Parameter. Status Description returned with the response. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
DECLARE @URL nvarchar(4000) DECLARE @FileEncoding varchar(100) DECLARE @FileContent varchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) SET @URL = 'ftp://speedtest.tele2.net/1KB.zip' SET @FileEncoding = 'ASCII' EXEC SQLHTTP.net.FTP_FileRead @URL = @URL, @FileEncoding = @FileEncoding, @FileContent = @FileContent OUTPUT, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT SELECT DATALENGTH(@FileContent) AS FileLength, @StatusCode AS StatusCode, @StatusDescription AS StatusDescription |
1 2 3 4 5 |
FileLength StatusCode StatusDescription ------------ ------------ ------------------------------------------------------------------ 1024 150 150 Opening BINARY mode data connection for 1KB.zip (1024 bytes). |