I'm trying to return a list of database backup files for backups which contain spaces in the file nameDECLARE @CmdString VARCHAR(200), @SysDate INTSET @SysDate = 101DROP TABLE #tmpFilesCREATE TABLE #tmpFiles(FileName varchar(150) )INSERT INTO #tmpFilesEXEC master.dbo.xp_cmdshell 'dir "D:\Backups\*.bak"'DELETEFROM #tmpFilesWHERE Filename NOT LIKE '%bak'OR Filename IS NULLSELECT REVERSE( SUBSTRING( REVERSE(Filename), 0, CHARINDEX(' ', REVERSE(Filename) ) ) ), SUBSTRING(Filename, 1, 22)FROM #tmpFilesWHERE DATEDIFF( dd, CONVERT(DATETIME, LEFT( Filename, 20),@SysDate), GETDATE() ) > 3The above will return all the files but not if they have a space in the file nameie.I have 2x backup files in D:\Backups called ;test_backup.baktest backup.bakAll that gets returned by the SELECT statement is ;test_backup.bakbackup.bakAnybody got any ideas how i change the select to return the entire file name and not work off the leading space?Any help appreciated