Michael Valentine Jones (7/22/2009)
This is a farily simple method:
declare @files table (cmdout nvarchar(100) )
insert into @files ( cmdout )
-- Get filenames excluding directories
exec master.dbo.xp_cmdshell 'dir C:\ /b /a:-d'
select cmdout from @files where cmdout is not null order by cmdout
Results:
cmdout
-------------------
AUTOEXEC.BAT
BOOT.BAK
boot.ini
cmldr
CONFIG.SYS
IO.SYS
license.txt
MSDOS.SYS
ntdetect.com
ntldr
pagefile.sys
Simpler still is EXEC Master.dbo.xp_Dirtree 'path/filename',1,1 but that isn't what the OP asked for either. He wants the dates for each file, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.