How to update the column without loop in SQL Server?
问题 Due to performance perspective I just need to remove loop and using some joins or other solution to update the data in #Result table and get the same result which return by loop. Scalar function: CREATE FUNCTION [MultiplyerScl] (@a INT, @b INT) RETURNS INT AS BEGIN DECLARE @i AS INT = 2 DECLARE @Value AS INT IF (@b % @a = 0) BEGIN SET @Value = @b END ELSE BEGIN WHILE (1=1) BEGIN IF((@b * @i) % @a = 0) BEGIN SET @Value = @b * @i BREAK; END ELSE BEGIN SET @i = @i + 1 END END END RETURN @Value