Create directory taking path from Table
Hi, I need to create directories taking distinct path from a DIRECTORY_MASTER table. The table values like "Dir1\Dir2\Dir3" or "Dir4\Dir5\Dir6" ......... The Fixed path is C:\OUTPUT I need to create directories like C:\OUTPUT\Dir1\Dir2\Dir3 and C:\OUTPUT\Dir4\Dir5\Dir6 and so on. Thanks Paritosh
January 18th, 2011 6:46am

Set up a Variable and set its EvaluateAsExpression as True. Set the Expression to concatanate the 'base' varialbe (contains "C:\OUTPUT\") and the looping variable that gets assigned from the table (contains "Dir1\Dir2", etc.) Just rememeber that if you need to put in literal backslashes in your Expression that they need to be doubled to 'escpae' them. Hope this helps.Todd C - MSCTS SQL Server 2005 - Please mark posts as answered where appropriate.
Free Windows Admin Tool Kit Click here and download it now
January 18th, 2011 7:08am

I am using "For each loop" where I am not able to put the query(select distinct path from DIRECTORY_MASTER ) using "Foreach ADO Enumerator".
January 18th, 2011 7:46am

OK, This should be your overall package design: First is an Execute SQL task with the above query "SELECT DISTINCT [Path] FROM dbo.DIRECTORY_MASTER" (I suggest you include Schema name as well as table name). Set the Result Set to Full Result Set, then on the Results page, add an entry named "0" and send it to a Variable of type Object named "Path_List" This will load the rows from the query into a table-type variable. Next is your For Each loop, and it should be set to enumerate over the ADO Recordset and select the Object Variable User::Path_List. Set up a Variable Mapping (again, named 0) and map the one output column to a String Variable named "thisPath". Now, each time through the loop, the variable User::thisPath will contain the next row from table User::Path_List. Inside the loop, put in your File System Task to create the folder. Create a string Variable called "FullPath" and set it to Evaluate As Expression. Set the Expression as "C:\\OUTPUT\\" + User::thisPath Set the Create Folder task to use the User::FullPath variable as the SourceVariableTodd C - MSCTS SQL Server 2005 - Please mark posts as answered where appropriate.
Free Windows Admin Tool Kit Click here and download it now
January 18th, 2011 8:52am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics