this is basically the same but takes into account a value with only the name (no path)declare @tbl1 table(ID INT,FilePath varchar(255))INSERT INTO @tbl1SELECT 1, 'c:\abc\aa.txt'INSERT INTO @tbl1SELECT 2, 'f:\mnop\tt.xml'INSERT INTO @tbl1SELECT 3, '\\mycomp\me\mm.pp.nn.zz'INSERT INTO @tbl1SELECT 4, '\\yourcomp\doc\new folder\ff33.333.33.xml'INSERT INTO @tbl1 SELECT 5, 'ff33.333.33.xml'select filePath ,FileName = right(filePath, isNull(nullif(charindex('\', reverse(filepath)),0)-1,len(filepath))) from @tbl1output:filePath FileName---------------------------------------------------------------------c:\abc\aa.txt aa.txtf:\mnop\tt.xml tt.xml\\mycomp\me\mm.pp.nn.zz mm.pp.nn.zz\\yourcomp\doc\new folder\ff33.333.33.xml ff33.333.33.xmlff33.333.33.xml ff33.333.33.xmlBe One with the OptimizerTG