on 2013 Sep 18 10:26 AM
Hello,
i need a sql statement to count files in a folder strukture
this should be the result Startpath is users Folderpath ;Filecount /Users/miller ; 5 Files /Users/miller/test ; 20 Files /Users/smith/ ; 664 Files
Have a look at "Directory access servers" SA12 DCX. Using CREATE SERVER, CREATE EXTERNLOGN and CREATE EXISTING TABLE you will be able to scan the folder (and subfolders, if specified). Example:
CREATE SERVER "FolderSample" CLASS 'DIRECTORY' USING 'ROOT=C:/Users;SUBDIRS=1;CREATEDIRS=NO;READONLY=YES'; CREATE EXTERNLOGIN "dba" TO "FolderSample"; CREATE EXISTING TABLE "sirius"."UserDir" ( "permissions" VARCHAR(10) NOT NULL, "size" BIGINT NOT NULL, "access_date_time" "datetime" NOT NULL, "modified_date_time" "datetime" NOT NULL, "create_date_time" "datetime" NOT NULL, "owner" VARCHAR(20) NOT NULL, "file_name" VARCHAR(260) NOT NULL, "contents" LONG BINARY NOT NULL ) AT 'FolderSample;;;.'; select file_name from UserDir where file_name like '%.csv'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When using SA 16, you would prefer to use the brand new Directory and file system procedures, particularly the sp_list_directory system procedure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
67 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.