July 29, 2011 at 5:35 pm
I am using this syntax to get the contents of a directory:
DECLARE @Files1 table (FileName varchar(50), col1 INT, col2 INT)
DECLARE @strDirectory varchar(150) = 'E:\MyDir\'
INSERT INTO @Files1(FileName, col1, col2)
EXEC.master.dbo.xp_DirTree @strDirectory, 1,1
This script is running on the server and I can get directories that are on the server. But how do I get a directory on an external hard drive attached to one of the network boxes? I am trying to compare a directory on the server to a directory on a backup hard drive.
Thanks for the help!!
Sam
August 1, 2011 at 4:08 am
Map the drive or use full path :
\\machinename\c$ ...
But, why are you using SQL for this? PowerShell or old dos-batch are designed exactly fo the purpose you have.
August 4, 2011 at 9:19 am
Eugene Elutin (8/1/2011)
Map the drive or use full path :\\machinename\c$ ...
But, why are you using SQL for this? PowerShell or old dos-batch are designed exactly fo the purpose you have.
+1 for PowerShell
...not to mention that xp_dirtree is undocumented, i.e. it could be removed or changed in a future version or patch of SQL Server with no notice!
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply