Above query works well if your function returns only one row, it will not be accurate if your function returns more than one row. In that case you should put your result to a temp table and process each rows using while loop as shown below.
SELECT @NewValue1 = Col1, @NewValue2 = Col2 FROM from dbo.fn_MyFunction(1)
DECLARE @temp table (ID INT IDENTITY, NewValue1 INT, NewValue2 INT) DECLARE @MaxRows INT, @ID INT = 1, @NewValue1 INT, @NewValue2 INT INSERT INTO @temp SELECT Col1, Col2 FROM dbo.fn_MyFunction(1) SELECT @MaxRows = MAX(ID) FROM @temp WHILE (@ID <= @MaxID) BEGIN SEECT @NewValue1 = NewValue1, @NewValue2 = NewValue2 FROM @temp WHERE ID = @ID SET @ID = @ID+1 END
12 People are following this question.