July 4, 2006 at 9:14 am
July 5, 2006 at 7:00 am
Hello mate,
This will do the trick - simply inserting the DIR result set in to a table and then reading that table.
Its a temp table, so please try not to run this kind of thing adhocly on a live production server!
declare
@scmdstring varchar(1000),
@sFileLocation varchar(255),
@sFileSearch varchar(20)
SET
@sFileLocation = '\\servername\c$'
SET
@sFileSearch = '*.*'
SELECT
@sCmdString = 'dir '+ @sFileLocation + @sFileSearch + ' /B'
@sCmdString
CREATE
TABLE #Directory
(
Filename varchar(255) NULL)
INSERT INTO #Directory EXEC master.dbo.xp_cmdshell @sCmdString
You will also have to enable XP_CMDSHELL in SQL 2005 as it is turned off option.
Let me know how you get on.
cheers
Mike
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply