FTP_FileDownload
Downloads a file from a remote FTP Server
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.FTP_FileDownload @URL, [@UserName], [@Password], @LocalFilePath, [@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
|
@LocalFilePath | nvarchar(4000) | Required. Destination file path for the downloaded file.
|
@StatusCode | int | Optional. Output Parameter. Numeric status of the response.
|
@StatusDescription | nvarchar(MAX) | Optional. Output Parameter. Status Description returned with the response. |
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 15 16 17 18 19 |
DECLARE @URL nvarchar(4000) DECLARE @LocalFilePath varchar(4000) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) SET @URL = 'ftp://speedtest.tele2.net/1KB.zip' --C:\Users\Admin\AppData\Local\Temp\ SET @LocalFilePath = SQLHTTP.net.TempPath() + '1KB.zip' EXEC SQLHTTP.net.FTP_FileDownload @URL = @URL, @LocalFilePath = @LocalFilePath, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT SELECT @StatusCode AS StatusCode, @StatusDescription AS StatusDescription |
1 2 3 4 5 |
StatusCode StatusDescription ------------ ------------------------------------------------------------------ 150 150 Opening BINARY mode data connection for 1KB.zip (1024 bytes). |