Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««23456»»

XP_cmdshell DIR Expand / Collapse
Author
Message
Posted Wednesday, July 13, 2011 7:42 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 8:19 AM
Points: 811, Visits: 3,210
Are you allowed to use CLR?

I got fed up with a number of work-arounds I had to get file information, so I created a CLR-based TVF to return several attributes of files in a passed-in directory. This made it easy to get things like the filename both with and without the file extension, the archive bit (which I really needed, so I could run an agent job and look for backup files that didn't go off to tape), etc.

This was one of my first forays into CLR, and the syntax of creating a TVF was a little odd to me, but there were some excellent examples here:
http://nclsqlclrfile.codeplex.com/
and here:
http://www.sqlservercentral.com/articles/SQLCLR/65656/
that I used as go-bys.

Rich
Post #1141000
Posted Tuesday, July 29, 2014 9:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 3, 2015 7:52 AM
Points: 1, Visits: 15
I am using SQL 2012, wanting to use DirTree to capture folder/subfolders within a share on a server - I can path to the UNC via Windows explorer with no issue - as it uses the local admins auth to that share via that method, however when xp_dirtree runs the credentials it uses are anonymous. can i use SetCred someplace to have windows store the credentials and put the user name in my script?

thanks!
Post #1597360
Posted Thursday, April 2, 2015 8:44 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, April 15, 2015 2:32 PM
Points: 3, Visits: 163
I modified Jeff's procedure to allow for subfolders. I put a maxDepth parameter into it for some control as needed. Thanks Jeff for the code.

ALTER PROCEDURE dbo.GetDirDetails
/**************************************************************************************************
Purpose:
Replacement code for the sp_GetFileDetails proc that was available in SQL Server 2000
which is no longer available in SQL Server 2005 except this gets all the file details
for all the files in the directory provided.

Notes:
1. If the directory does not exist or there are no files in the directory, an empty
result set will be returned.
2. If the trailing backslash on the path is missing, it will be added automatically.
3. No error checking is done. Either a valid result set is returned or an empty
result set is returned (much like a function operates).

Usage:
EXEC dbo.GetDirDetails 'drive:path or UNC'

Revision History:
Rev 00 - 05/23/2008 - Jeff Moden
- Initial concept borrowed from Simple-Talk.com (Phil Factor) and
modified for multiple files.
Rev 01 - 05/25/2008 - Jeff Moden
- Formalize the code for use.
Rev 02 - 04/02/2015 - Stephen Swan
- Altered code to allow for subdirectories
**************************************************************************************************/
--===== Declare the I/O parameters
@piFullPath VARCHAR(128), @maxDepth INT
AS

--===== Suppress the auto-display of rowcounts so as not to interfere with the returned
-- result set
--SET NOCOUNT ON

--=================================================================================================
-- Local variables
--=================================================================================================
--===== These are processing control and reporting variables
DECLARE @Counter INT --General purpose counter
DECLARE @CurrentName VARCHAR(256) --Name of file currently being worked
DECLARE @DirTreeCount INT --Remembers number of rows for xp_DirTree
DECLARE @IsFile BIT --1 if Name is a file, 0 if not

--===== These are object "handle" variables
DECLARE @ObjFile INT --File object
DECLARE @ObjFileSystem INT --File System Object

--===== These variable names match the sp_OAGetProperty options
-- Made names match so they're less confusing
DECLARE @Attributes INT --Read only, Hidden, Archived, etc, as a bit map
DECLARE @DateCreated DATETIME --Date file was created
DECLARE @DateLastAccessed DATETIME --Date file was last read (accessed)
DECLARE @DateLastModified DATETIME --Date file was last written to
DECLARE @Name VARCHAR(128) --File Name and Extension
DECLARE @Path VARCHAR(128) --Full path including file name
DECLARE @ShortName VARCHAR(12) --8.3 file name
DECLARE @ShortPath VARCHAR(100) --8.3 full path including file name
DECLARE @Size INT --File size in bytes
DECLARE @Type VARCHAR(100) --Long Windows file type (eg.'Text Document',etc)

--=================================================================================================
-- Create temporary working tables
--=================================================================================================
--===== Create a place to store all file names derived from xp_DirTree
--IF OBJECT_ID('TempDB..@DirTree','U') IS NOT NULL
-- DROP TABLE @DirTree

DECLARE @DirTree TABLE
(
RowNum INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name VARCHAR(256),
Depth INT,
IsFile INT,
ParentNum VARCHAR(255),
FilePath VARCHAR(255)
)

--===== Create a place to store the file details so we can return all the file details
-- as a single result set
--IF OBJECT_ID('TempDB..@FileDetails','U') IS NOT NULL
-- DROP TABLE @FileDetails

DECLARE @FileDetails TABLE
(
RowNum INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name VARCHAR(128), --File Name and Extension
Path VARCHAR(128), --Full path including file name
ShortName VARCHAR(12), --8.3 file name
ShortPath VARCHAR(100), --8.3 full path including file name
DateCreated DATETIME, --Date file was created
DateLastAccessed DATETIME, --Date file was last read
DateLastModified DATETIME, --Date file was last written to
Attributes INT, --Read only, Compressed, Archived
ArchiveBit AS CASE WHEN Attributes& 32=32 THEN 1 ELSE 0 END,
CompressedBit AS CASE WHEN Attributes&2048=2048 THEN 1 ELSE 0 END,
ReadOnlyBit AS CASE WHEN Attributes& 1=1 THEN 1 ELSE 0 END,
Size INT, --File size in bytes
Type VARCHAR(100) --Long Windows file type (eg.'Text Document',etc)
)

--=================================================================================================
-- Make sure the full path name provided ends with a backslash
--=================================================================================================
SELECT @piFullPath = @piFullPath+'\'
WHERE RIGHT(@piFullPath,1)<>'\'

--=================================================================================================
-- Get all the file names for the directory (includes directory names as IsFile = 0)
--=================================================================================================
--===== Get the file names for the desired path
-- Note that xp_DirTree is available in SQL Server 2000, 2005, and 2008.
INSERT INTO @DirTree (Name, Depth, IsFile)
EXEC master.dbo.xp_dirtree @piFullPath, @maxDepth, 1

-- Mark Parent Directory id
UPDATE d
SET d.ParentNum = (SELECT MAX(DT.RowNum) FROM @DirTree DT WHERE DT.Depth = d.Depth - 1 AND DT.RowNum < d.RowNum)
FROM @DirTree d;

-- Recurse through records to put together folder names
WITH CTE AS (
SELECT RowNum, CAST(Name as nvarchar(255)) as Name,
Depth, ParentNum, CAST('' as nvarchar(255)) as Parent
FROM @DirTree WHERE ParentNum IS NULL
UNION ALL
SELECT d.RowNum, CAST(d.Name as nvarchar(255)),
d.Depth, d.ParentNum, CAST(CTE.Name as nvarchar(255))
FROM @DirTree d
INNER JOIN CTE ON d.ParentNum = CTE.RowNum
)
UPDATE DT
SET FilePath = CASE WHEN CTE.ParentNum IS NULL THEN @piFullPath ELSE @piFullPath + ISNULL(CTE.Parent + '\','') END
FROM CTE
INNER JOIN @DirTree DT ON CTE.RowNum = DT.RowNum

-- Remove folders from listing as they are no longer necessary
DELETE FROM @DirTree
WHERE IsFile <> 1

-- Remember the row count
SELECT @DirTreeCount = COUNT(1) FROM @DirTree

--=================================================================================================
-- Get the properties for each file. This is one of the few places that a WHILE
-- loop is required in T-SQL.
--=================================================================================================
--===== Create a file system object and remember the "handle"
EXEC dbo.sp_OACreate 'Scripting.FileSystemObject', @ObjFileSystem OUT

--===== Step through the file names and get the properties for each file.
SET @Counter = 1
WHILE @Counter <= @DirTreeCount
BEGIN
--===== Get the current name
SELECT @CurrentName = FilePath + Name
FROM @DirTree
WHERE RowNum = @Counter

IF @CurrentName IS NOT NULL BEGIN

--===== Get File Details
--===== Create an object for the path/file and remember the "handle"
EXEC dbo.sp_OAMethod @ObjFileSystem,'GetFile', @ObjFile OUT, @CurrentName

--===== Get the all the required attributes for the file itself
EXEC dbo.sp_OAGetProperty @ObjFile, 'Path', @Path OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'ShortPath', @ShortPath OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Name', @Name OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'ShortName', @ShortName OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateCreated', @DateCreated OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateLastAccessed', @DateLastAccessed OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateLastModified', @DateLastModified OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Attributes', @Attributes OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Size', @Size OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Type', @Type OUT

--===== Insert the file details into the return table
INSERT INTO @FileDetails
(Path, ShortPath, Name, ShortName, DateCreated,
DateLastAccessed, DateLastModified, Attributes, Size, Type)
SELECT @Path,@ShortPath,@Name,@ShortName,@DateCreated,
@DateLastAccessed,@DateLastModified,@Attributes,@Size,@Type
END

--===== Increment the loop counter to get the next file or quit
SELECT @Counter = @Counter + 1
END

--===== House keeping, destroy and drop the file objects to keep memory leaks from happening
EXEC sp_OADestroy @ObjFileSystem
EXEC sp_OADestroy @ObjFile

--===== Return the details for all the files as a single result set.
-- This is one of the few places in T-SQL where SELECT * is ok.
SELECT * FROM @FileDetails

Post #1673913
Posted Thursday, April 2, 2015 6:26 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:22 PM
Points: 37,990, Visits: 34,893
Stephen Swan (4/2/2015)
I modified Jeff's procedure to allow for subfolders. I put a maxDepth parameter into it for some control as needed. Thanks Jeff for the code.

ALTER PROCEDURE dbo.GetDirDetails
/**************************************************************************************************
Purpose:
Replacement code for the sp_GetFileDetails proc that was available in SQL Server 2000
which is no longer available in SQL Server 2005 except this gets all the file details
for all the files in the directory provided.

Notes:
1. If the directory does not exist or there are no files in the directory, an empty
result set will be returned.
2. If the trailing backslash on the path is missing, it will be added automatically.
3. No error checking is done. Either a valid result set is returned or an empty
result set is returned (much like a function operates).

Usage:
EXEC dbo.GetDirDetails 'drive:path or UNC'

Revision History:
Rev 00 - 05/23/2008 - Jeff Moden
- Initial concept borrowed from Simple-Talk.com (Phil Factor) and
modified for multiple files.
Rev 01 - 05/25/2008 - Jeff Moden
- Formalize the code for use.
Rev 02 - 04/02/2015 - Stephen Swan
- Altered code to allow for subdirectories
**************************************************************************************************/
--===== Declare the I/O parameters
@piFullPath VARCHAR(128), @maxDepth INT
AS

--===== Suppress the auto-display of rowcounts so as not to interfere with the returned
-- result set
--SET NOCOUNT ON

--=================================================================================================
-- Local variables
--=================================================================================================
--===== These are processing control and reporting variables
DECLARE @Counter INT --General purpose counter
DECLARE @CurrentName VARCHAR(256) --Name of file currently being worked
DECLARE @DirTreeCount INT --Remembers number of rows for xp_DirTree
DECLARE @IsFile BIT --1 if Name is a file, 0 if not

--===== These are object "handle" variables
DECLARE @ObjFile INT --File object
DECLARE @ObjFileSystem INT --File System Object

--===== These variable names match the sp_OAGetProperty options
-- Made names match so they're less confusing
DECLARE @Attributes INT --Read only, Hidden, Archived, etc, as a bit map
DECLARE @DateCreated DATETIME --Date file was created
DECLARE @DateLastAccessed DATETIME --Date file was last read (accessed)
DECLARE @DateLastModified DATETIME --Date file was last written to
DECLARE @Name VARCHAR(128) --File Name and Extension
DECLARE @Path VARCHAR(128) --Full path including file name
DECLARE @ShortName VARCHAR(12) --8.3 file name
DECLARE @ShortPath VARCHAR(100) --8.3 full path including file name
DECLARE @Size INT --File size in bytes
DECLARE @Type VARCHAR(100) --Long Windows file type (eg.'Text Document',etc)

--=================================================================================================
-- Create temporary working tables
--=================================================================================================
--===== Create a place to store all file names derived from xp_DirTree
--IF OBJECT_ID('TempDB..@DirTree','U') IS NOT NULL
-- DROP TABLE @DirTree

DECLARE @DirTree TABLE
(
RowNum INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name VARCHAR(256),
Depth INT,
IsFile INT,
ParentNum VARCHAR(255),
FilePath VARCHAR(255)
)

--===== Create a place to store the file details so we can return all the file details
-- as a single result set
--IF OBJECT_ID('TempDB..@FileDetails','U') IS NOT NULL
-- DROP TABLE @FileDetails

DECLARE @FileDetails TABLE
(
RowNum INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
Name VARCHAR(128), --File Name and Extension
Path VARCHAR(128), --Full path including file name
ShortName VARCHAR(12), --8.3 file name
ShortPath VARCHAR(100), --8.3 full path including file name
DateCreated DATETIME, --Date file was created
DateLastAccessed DATETIME, --Date file was last read
DateLastModified DATETIME, --Date file was last written to
Attributes INT, --Read only, Compressed, Archived
ArchiveBit AS CASE WHEN Attributes& 32=32 THEN 1 ELSE 0 END,
CompressedBit AS CASE WHEN Attributes&2048=2048 THEN 1 ELSE 0 END,
ReadOnlyBit AS CASE WHEN Attributes& 1=1 THEN 1 ELSE 0 END,
Size INT, --File size in bytes
Type VARCHAR(100) --Long Windows file type (eg.'Text Document',etc)
)

--=================================================================================================
-- Make sure the full path name provided ends with a backslash
--=================================================================================================
SELECT @piFullPath = @piFullPath+'\'
WHERE RIGHT(@piFullPath,1)<>'\'

--=================================================================================================
-- Get all the file names for the directory (includes directory names as IsFile = 0)
--=================================================================================================
--===== Get the file names for the desired path
-- Note that xp_DirTree is available in SQL Server 2000, 2005, and 2008.
INSERT INTO @DirTree (Name, Depth, IsFile)
EXEC master.dbo.xp_dirtree @piFullPath, @maxDepth, 1

-- Mark Parent Directory id
UPDATE d
SET d.ParentNum = (SELECT MAX(DT.RowNum) FROM @DirTree DT WHERE DT.Depth = d.Depth - 1 AND DT.RowNum < d.RowNum)
FROM @DirTree d;

-- Recurse through records to put together folder names
WITH CTE AS (
SELECT RowNum, CAST(Name as nvarchar(255)) as Name,
Depth, ParentNum, CAST('' as nvarchar(255)) as Parent
FROM @DirTree WHERE ParentNum IS NULL
UNION ALL
SELECT d.RowNum, CAST(d.Name as nvarchar(255)),
d.Depth, d.ParentNum, CAST(CTE.Name as nvarchar(255))
FROM @DirTree d
INNER JOIN CTE ON d.ParentNum = CTE.RowNum
)
UPDATE DT
SET FilePath = CASE WHEN CTE.ParentNum IS NULL THEN @piFullPath ELSE @piFullPath + ISNULL(CTE.Parent + '\','') END
FROM CTE
INNER JOIN @DirTree DT ON CTE.RowNum = DT.RowNum

-- Remove folders from listing as they are no longer necessary
DELETE FROM @DirTree
WHERE IsFile <> 1

-- Remember the row count
SELECT @DirTreeCount = COUNT(1) FROM @DirTree

--=================================================================================================
-- Get the properties for each file. This is one of the few places that a WHILE
-- loop is required in T-SQL.
--=================================================================================================
--===== Create a file system object and remember the "handle"
EXEC dbo.sp_OACreate 'Scripting.FileSystemObject', @ObjFileSystem OUT

--===== Step through the file names and get the properties for each file.
SET @Counter = 1
WHILE @Counter <= @DirTreeCount
BEGIN
--===== Get the current name
SELECT @CurrentName = FilePath + Name
FROM @DirTree
WHERE RowNum = @Counter

IF @CurrentName IS NOT NULL BEGIN

--===== Get File Details
--===== Create an object for the path/file and remember the "handle"
EXEC dbo.sp_OAMethod @ObjFileSystem,'GetFile', @ObjFile OUT, @CurrentName

--===== Get the all the required attributes for the file itself
EXEC dbo.sp_OAGetProperty @ObjFile, 'Path', @Path OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'ShortPath', @ShortPath OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Name', @Name OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'ShortName', @ShortName OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateCreated', @DateCreated OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateLastAccessed', @DateLastAccessed OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'DateLastModified', @DateLastModified OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Attributes', @Attributes OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Size', @Size OUT
EXEC dbo.sp_OAGetProperty @ObjFile, 'Type', @Type OUT

--===== Insert the file details into the return table
INSERT INTO @FileDetails
(Path, ShortPath, Name, ShortName, DateCreated,
DateLastAccessed, DateLastModified, Attributes, Size, Type)
SELECT @Path,@ShortPath,@Name,@ShortName,@DateCreated,
@DateLastAccessed,@DateLastModified,@Attributes,@Size,@Type
END

--===== Increment the loop counter to get the next file or quit
SELECT @Counter = @Counter + 1
END

--===== House keeping, destroy and drop the file objects to keep memory leaks from happening
EXEC sp_OADestroy @ObjFileSystem
EXEC sp_OADestroy @ObjFile

--===== Return the details for all the files as a single result set.
-- This is one of the few places in T-SQL where SELECT * is ok.
SELECT * FROM @FileDetails



You're welcome but just expanding the range of the DirTree doesn't solve the problem of subdirectories. When I run the code above, it returns many duplicates and none of the subdirectory information.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1674055
Posted Friday, April 3, 2015 10:22 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 11:09 PM
Points: 4,160, Visits: 10,709
I know I'm somewhat late to the show, haven't read through the whole trail and therefore might be missing something, but my approach would be the xp_cmdshell with "dir /S /N /C" and then filter and parse the results, in my experience it's much more efficient than creating an OLE Object.
Post #1674264
Posted Friday, April 3, 2015 11:11 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:22 PM
Points: 37,990, Visits: 34,893
Eirikur Eiriksson (4/3/2015)
I know I'm somewhat late to the show, haven't read through the whole trail and therefore might be missing something, but my approach would be the xp_cmdshell with "dir /S /N /C" and then filter and parse the results, in my experience it's much more efficient than creating an OLE Object.


I absolutely agree but the stigma that some DBAs have against using xp_CmdShell is frightening while there is less of a stigma about using OLE objects. Where one may not be allowed, the other might.



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1674272
Posted Friday, April 3, 2015 11:30 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 11:09 PM
Points: 4,160, Visits: 10,709
Jeff Moden (4/3/2015)
Eirikur Eiriksson (4/3/2015)
I know I'm somewhat late to the show, haven't read through the whole trail and therefore might be missing something, but my approach would be the xp_cmdshell with "dir /S /N /C" and then filter and parse the results, in my experience it's much more efficient than creating an OLE Object.


I absolutely agree but the stigma that some DBAs have against using xp_CmdShell is frightening while there is less of a stigma about using OLE objects. Where one may not be allowed, the other might.



All this because of the misconfiguration of the defaults in the past. I find managing the xp_CmdShell permissions a lot easier than the OLE opbject creation, far too easy to spoof and seed malicious objects when all you have to go with are GUID references/object names. Another aspect is the memory allocation to the OLE thingies, far from optimal (correct me if I'm wrong) as still being a percentage of the available memory
Post #1674280
Posted Friday, April 3, 2015 9:58 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:22 PM
Points: 37,990, Visits: 34,893
IT's much simpler than all that. Both require "SA" privs to be used. Both can only be turned on or of by someone with "SA" privs. Control who has "SA" privs.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1674360
Posted Thursday, April 23, 2015 9:50 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:43 AM
Points: 1,712, Visits: 2,355
Awesome Post. Thanks Jeff Sir...

Thanks.
Post #1679639
Posted Thursday, April 23, 2015 9:55 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:43 AM
Points: 1,712, Visits: 2,355
Can you please suggest all the files from one location to another using the temp table (#FileDetails)?

I have a rmeote location where I want to copy all the files from local server to remote share.

I have xp_cmdshell offers copy/move features but wanted to know if you have drafted already any other good script, can make use of it.

Fianlly great script..


Thanks.
Post #1679641
« Prev Topic | Next Topic »

Add to briefcase «««23456»»

Permissions Expand / Collapse