SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Create Folders using SQL table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ph1long
Starting Member

16 Posts

Posted - 01/03/2013 :  15:50:06  Show Profile  Reply with Quote
Hi,

I have filenames such as:

FD3_2012-10_Stmt.pdf
FD6_2012-10_Stmt.pdf
AAA_2012-10_Stmt.pdf

listed in a table called "Reports".

Is there a way to:

1. Create (X) number of random folder names in a table ("X" depends on how many file names I have in the table.
2. Use these names to create folders on the C: drive.
3. Place the files in their corresponding folders?

Thanks

Edited by - ph1long on 01/03/2013 15:52:00

TG
Flowing Fount of Yak Knowledge

USA
6059 Posts

Posted - 01/03/2013 :  17:24:20  Show Profile  Reply with Quote
I assume you are asking for a programmatic solution?

1. sounds like you simply want to add rows in one table based on the rows in another table?
That is easy with t-sql.

2 and 3. These both involve interaction with the file system. The best way to do that is with either application code (ie .net app) or with integrated code solution (ie CLR). .net has Class libraries with functionality to perform these typs of things. (ie System.IO.FileInfo)


Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 01/04/2013 :  02:55:39  Show Profile  Reply with Quote
1 same as what TG suggested
2 and 3 you could use File System Task available in SSIS to create folders. the looping can be implemented by means of ForEachLoop task. Also files can be moved using Move File functionality in SSIS

Sample packages using File System Task and ForEachLoop can be found here

http://visakhm.blogspot.in/2012/12/selective-file-archiving-using-ssis.html

http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000