I've been able to use the xp_cmdshell to get a list of file names from a given server directory, using the following:
How can I get the "Date Modified" for each file into a separate column?
I've used the following code to get in the ballpark, but I was hoping to get a cleaner result set (i.e. "File Name" & "Date Modified"):
Many thanks to Catadmin and others for providing the useful code I've used thus far.
Regards,
Joe
Code:
CREATE TABLE #Files (MyFile varchar(200))
DECLARE @Path varchar(400)
SET @Path = 'D:\Basel\Inquiry\'
EXECUTE sp_ListFiles @Path,'#Files','%.dbf',NULL,0
SELECT * FROM #Files
order by MyFile DESC
DROP TABLE #Files
How can I get the "Date Modified" for each file into a separate column?
I've used the following code to get in the ballpark, but I was hoping to get a cleaner result set (i.e. "File Name" & "Date Modified"):
Code:
create table #Backup (Filename varchar(250))
Declare @Filename varchar(250),
@RemoveFile varchar(100),
@Directory varchar(250),
@MyDate datetime,
@LongFileName varchar(200)
Set @Directory = '"dir D:\Basel\Inquiry"'
Insert into #Backup
exec master..xp_cmdshell @Directory
delete
from #Backup
where Filename is null
GO
select * from #Backup
drop table #Backup
Many thanks to Catadmin and others for providing the useful code I've used thus far.
Regards,
Joe