I'm anti-cursor so I would use a WHILE loop, but that is up to you. Here is some sampe code that may help you:-- Set upDECLARE @File TABLE(FileName VARCHAR(50))INSERT @FileSELECT 'a_01112007_100001.txt'UNION ALL SELECT 'b_01112007_090001.txt'UNION ALL SELECT 'c_01112007_080001.txt'-- This could be used to load the cursor, but this is a VARCHAR sort not a date sortSELECT RIGHT(PARSENAME(FileName, 2), LEN(PARSENAME(FileName, 2)) - (CHARINDEX('_', PARSENAME(FileName, 2))))FROM @FileORDER BY RIGHT(PARSENAME(FileName, 2), LEN(PARSENAME(FileName, 2)) - (CHARINDEX('_', PARSENAME(FileName, 2))))-- This is how you could convert the file name to an acutal DATETIME for proper orderingSELECT CAST(REPLACE(STUFF(STUFF(STUFF(STUFF(RIGHT(PARSENAME(FileName, 2), LEN(PARSENAME(FileName, 2)) - (CHARINDEX('_', PARSENAME(FileName, 2)))), 3, 0, '-'), 6, 0, '-'), 14, 0, ':'), 17, 0, ':'), '_', ' ') AS DATETIME)FROM @File