Is it possible to specify a step in the interval when inserting a set of values into a table using UPDATE in MS SQL? For example, I would like to update the values in the table, where the ID will be in the range from 100 to 500 in increments of 30. Or, alternatively, how can we manage without the interval so that the update takes place in a loop in a certain interval with a specific step? Below I will indicate an example of code in which I would like to implement it, if possible.
UPDATE Rates SET Amount = ( SELECT Amount FROM ( SELECT KK.Amount, KK.OperationName FROM ( SELECT R.Col1, R.RateID, JJ.Type, FLOOR(JJ.AmountMin + RAND() * (JJ.AmountMax + 1 - JJ.AmountMin)) AS Amount, JJ.OperationName, JJ.Currency FROM Rates R LEFT JOIN ( SELECT * FROM OriginTransacts OT WHERE OT.Period = 'Month' AND OT.OperationName = 'Clothes Shopping' ) AS JJ ON R.RateID = FLOOR(RAND() * 5 + 10) ) AS KK ) AS LL WHERE Amount IS NOT NULL ), OperationName = ( SELECT OperationName FROM ( SELECT KK.Amount, KK.OperationName FROM ( SELECT R.Col1, R.RateID, JJ.Type, FLOOR(JJ.AmountMin + RAND() * (JJ.AmountMax + 1 - JJ.AmountMin)) AS Amount, JJ.OperationName, JJ.Currency FROM Rates R LEFT JOIN ( SELECT * FROM OriginTransacts OT WHERE OT.Period = 'Month' AND OT.OperationName = 'Clothes Shopping' ) AS JJ ON R.RateID = FLOOR(RAND() * 5 + 10) ) AS KK ) AS LL WHERE Amount IS NOT NULL ) WHERE Rates.RateID IN(FLOOR(RAND() * 5 + 1110), FLOOR(RAND() * 5 + 1140), FLOOR(RAND() * 5 + 1170), FLOOR(RAND() * 5 + 1200), FLOOR(RAND() * 5 + 1230), FLOOR(RAND() * 5 + 1260), FLOOR(RAND() * 5 + 1290), FLOOR(RAND() * 5 + 1320), FLOOR(RAND() * 5 + 1350), FLOOR(RAND() * 5 + 1380), FLOOR(RAND() * 5 + 1410), FLOOR(RAND() * 5 + 1440)) AND Rates.Amount IS NULL;
WHILEwith an increment of +30 - AnatolWHILEtried, but did not work. Either I wrote the wrong script, or it does not work. - Daniyal Lukmanov