FTP_FolderRead
Returns the content of a directory on a remote FTP Server
- Stored Procedure
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
EXEC SQLHTTP.net.FTP_FolderRead @URL, [@UserName], [@Password], [@ShowDetails], [@StatusCode], [@StatusDescription]
Name | Type | Description |
---|---|---|
@URL | nvarchar(4000) |
Required. FTP address starting with ftp:// |
@UserName | nvarchar(200) |
Optional. Leave blank (NULL) for anonymous connections |
@Password | nvarchar(200) |
Optional. Leave blank (NULL) for anonymous connections |
@ShowDetails | bit |
Optional. Boolean value that indicates whether only paths and names are retrieved (0) or whether additional information is retrieved as well (1). Default: 0 (false) |
@StatusCode | int |
Optional. Output Parameter. Numeric status of the response. |
@StatusDescription | nvarchar(MAX) | Optional. Output Parameter. Status Description returned with the response. |
Returns a list of file names in a specified directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
DECLARE @URL nvarchar(4000) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Folder TABLE(List nvarchar(MAX)) SET @URL = 'ftp://speedtest.tele2.net/upload' INSERT INTO @Folder(List) EXEC SQLHTTP.net.FTP_FolderRead @URL = @URL, @ShowDetails = 0, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT IF @StatusCode = 150 BEGIN SELECT * FROM @Folder END ELSE BEGIN RAISERROR(@StatusDescription, 16, 1) END |
1 2 3 4 5 6 7 8 9 |
ListItem -------------- upload/4om9imsj1bdsaplqulu8j8u52r.txt upload/OD355306065314611_500000.bin upload/OD359471060790946_500000.bin upload/OD359471060838422_500000.bin upload/upload_file.txt |
Returns a detailed list of files in a specified directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
DECLARE @URL nvarchar(4000) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Folder TABLE(List nvarchar(MAX)) SET @URL = 'ftp://speedtest.tele2.net/upload' INSERT INTO @Folder(List) EXEC SQLHTTP.net.FTP_FolderRead @URL = @URL, @ShowDetails = 1, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT IF @StatusCode = 150 BEGIN SELECT * FROM @Folder END ELSE BEGIN RAISERROR(@StatusDescription, 16, 1) END |
1 2 3 4 5 6 7 8 9 10 |
ListItem ------------------------------------------------------------------------------------------------ -rw------- 1 105 108 43400 Nov 25 16:44 100MB.zip -rw------- 1 105 108 245676 Nov 25 16:41 4om9imsj1bdsaplqulu8j8u52r.txt -rw------- 1 105 108 24892464 Nov 25 16:44 OD355306065314611_500000.bin -rw------- 1 105 108 204916088 Nov 25 16:37 OD359471060790946_500000.bin -rw------- 1 105 108 21236684 Nov 25 16:44 OD359471060838422_500000.bin -rw------- 1 105 108 278004 Nov 25 16:44 upload_file.txt |