/****** Script for SelectTopNRows command from SSMS ******/ update [dongsheng2017ceshi].[dbo].[t_op_seae_ftpfile_bc] set [t_op_seae_ftpfile_bc].lastmodi_date= v2.mddate from ( select dateadd(hour,8, CONVERT(DATETIME,substring (mddate,1,4)+'-'+SUBSTRING(mddate,5,2)+'-'+SUBSTRING(mddate,7,2) + ' ' +SUBSTRING(mddate,9,2) + ':'+ SUBSTRING(mddate,11,2)+ ':'+ SUBSTRING(mddate,13,2) ) ) as mddate ,ID as id from ( SELECT SUBSTRING([ftp_filename],len([ftp_filename])-17,14 ) as mddate, [ID] FROM [dongsheng2017ceshi].[dbo].[t_op_seae_ftpfile_bc] t where t.remark='' ) v ) v2 where t_op_seae_ftpfile_bc .id=v2.id select dateadd(hour,2,GETDATE()),getdate()