Loop through column value and insert into another table

I have the following pseudo code and want to know if I am going about it properly. The background is I have a table that has ~138 million rows in it and I want to aggregate certain certain columns by some set of grouping variables. I want to do this on the [Timestamp] column which represents a snapshot date. There are roughly 4 million rows per snapshot.

Loop through column value and insert into another table

I have the following pseudo code and want to know if I am going about it properly. The background is I have a table that has ~138 million rows in it and I want to aggregate certain certain columns by some set of grouping variables. I want to do this on the [Timestamp] column which represents a snapshot date. There are roughly 4 million rows per snapshot.

I am trying to use case to set a parameter in my where clause

I have a file that intakes yearly totals for tax due and breaks it down by month like : fcurJanuaryTotal, fcurFebruaryTotal, fcurMarchTotal etc. When someone receives a notice to pay taxes on a given month I receive a ‘lead’ which sets the pay period in this format dd-mm-yyyy (in a column named ‘fdtmFilingPeriod’). I have a program that uses a query to create the lead and then create an estimated payment for their taxes and pulls the financials from the file I receive with the monthly totals. It is desired that no estimated payments be created that are less than $100.

All of a sudden not working, using linked server to source getting “Communication link failure”

These jobs were working then all of a sudden all jobs connecting to source server are getting “Communication link failure”. [SQLSTATE 01000] (Error 7412) OLE DB provider “SQLNCLI11” for linked server . We have tried same from another server to the source server and getting the same error. We can see the linked server and the db and tables etc.