| 
 | 
select top 10 *,datediff(ms,01 6 2017 1:14PM,getdate()) from #testtable where tid not in (select top 89990 a.tid from #testtable a order by a.tid desc) order by tid desc 
 
Take out your SQL analysis, datediff(ms,01 6 2017 1:14PM,getdate()), there are two single quotes missing in the middle, so single quotes should be added, and in the dynamic statement, two single quotes replace one apostrophe |   
 
 
 
 |