This code works when set @ToDate = '20200311' i.e. when I have hardcoded the specific date, but does not work when I want this to always execute till the current date
The line set @ToDate = select .....getdate.. throws error, can you please help me out and tell me what I should do to rectify?
While @@Fetchstatus =0,
begin
set @Fromdate = '20180102';
set @ToDate = select convert (varchar, getdate(), 112);
while (@Fromdate < @ToDate) begin
set @StrQuery = 'INSERT into dbo.Tmp_M_Rates (Rate_Date, Rate_D, Entity, cur) values ('
+''''+ CAST (@FromDate AS nvarchar) + ''', ''' + Substring (CONVERT (VARCHAR
(10), @Fromdate, 112),3,8) + ''', ''' + @EntityName + ''', ''' + @Cur +
''')'
EXEC (@StrQuery)
set @Fromdate = dateadd(DAY,1,@Fromdate)
end