Q: insert records in cycle MS SQL 
And SQL again.
My situation.
I need make insert into the table. I have the condition.
Some inserts can be doing if the equal their rates in the week and in the month.
For example: for category 2 rate = 1 time in month. So I need insert only one time in April. But in my case, it inserts 1 record I expected and inserts 5 additional times yet.
 SET @Rate_Init = 1 
 DECLARE @Min_Amount INT = (SELECT T.AccountMin FROM Transactions T 
 FULL JOIN Marathon.dbo.Categories C ON C.CategoryName = 
 T.OperationName WHERE C.CategoryID = @External_Loop_Counter)
 DECLARE @Max_Amount INT = (SELECT T.AccountMax FROM Transactions T 
 FULL JOIN Marathon.dbo.Categories C ON C.CategoryName = 
 T.OperationName WHERE C.CategoryID = @External_Loop_Counter)
 DECLARE @Check_Period NVARCHAR(10) = (SELECT Period  FROM (SELECT * 
 FROM Transactions T FULL JOIN Marathon.dbo.Categories C ON 
 C.CategoryName = T.OperationName) X WHERE CategoryID = 
 @External_Loop_Counter)            
 DECLARE @Frequency INT = (SELECT Rate  FROM (SELECT * FROM 
 Transactions T FULL JOIN Marathon.dbo.Categories C ON C.CategoryName 
 = T.OperationName) X WHERE CategoryID = @External_Loop_Counter)
 WHILE @Total_Dates >= @Internal_Loop_Counter
                    BEGIN

                    IF(@Frequency <= @Rate_Init)
                        BEGIN
                        INSERT INTO Transactions (TransactionDate, TransactionAmount, CategoryID)
                        VALUES((DATEADD(DAY, @Internal_Loop_Counter, @Start_DT)), (@Max_Amount - CAST(((@Max_Amount - @Min_Amount)) AS FLOAT)*RAND()),
                        (SELECT CategoryID FROM (SELECT * FROM Transactions T FULL JOIN Marathon.dbo.Categories C ON C.CategoryName = T.OperationName) X WHERE CategoryID = @External_Loop_Counter))
                        END 

                        SET @Rate_Init = @Rate_Init + 1
                    SET @Jump_Ratio = (
                    CASE
                    WHEN @Check_Period = 'Week' THEN (@Internal_Loop_Counter + CAST(CAST(@Week_T AS FLOAT)*RAND() AS INT))
                    WHEN @Check_Period = 'Month' THEN (@Internal_Loop_Counter + CAST(CAST(@Month_T AS FLOAT)*RAND() AS INT))
                    WHEN @Check_Period = 'Year' THEN (@Internal_Loop_Counter + CAST(CAST(@Year_T AS FLOAT)*RAND() AS INT))
                    END
                    )

                    SET @Internal_Loop_Counter = @Jump_Ratio + 1
                    END


Expect
140     2012-03-28 00:00:00 628 2
141     2012-04-26 00:00:00 334 2
142     2012-05-03 00:00:00 418 2

Actual result I had got
140     2012-03-28 00:00:00 628 2
141     2012-04-03 00:00:00 592 2
142     2012-04-04 00:00:00 353 2
143     2012-04-10 00:00:00 403 2
144     2012-04-16 00:00:00 635 2
145     2012-04-22 00:00:00 673 2
146     2012-04-26 00:00:00 334 2
147     2012-05-03 00:00:00 418 2
Use 2017 MS SQL

A: I had solved my problem. I had used 2 inner loops in external loop. And, of course, didn't forget to change steps of the loops
PS Here is no difference what exactly use - full or inner join
