Need help with query to find the latest record from the name. We store our folder file names in SQL table column which has the date. I would like to get the latest filename based on the date in the filename and store it in variable. In this particular case, it should display me 'T3_Datemart_Control_File.csv_20210607_23h32m02'
DECLARE @TableFileName TABLE
(FileName varchar(100))
insert into @TableFileName values ('T3_Datemart_Control_File.csv_20210407_23h02m06')
insert into @TableFileName values ('T3_Datemart_Control_File.csv_20210506_23h01m03')
insert into @TableFileName values ('T3_Datemart_Control_File.csv_20210607_23h32m02')
select * from @TableFileName