Я хочу использовать этот код, используя временную переменную, пожалуйста.
SELECT *
FROM Customers
DECLARE @name VARCHAR(50)
DECLARE @salary INT
CREATE TABLE #Result1 (Name VARCHAR(50), Salary INT)
DECLARE zxcv CURSOR FOR
SELECT
CASE
WHEN LEN(Name) <= 5
THEN CONCAT(Name, '_', LEN(Name))
ELSE Name
END,
Salary
FROM
Customers;
OPEN zxcv
FETCH NEXT FROM zxcv INTO @name, @salary;
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #Result1 (Name, Salary)
VALUES (@name, @salary);
FETCH NEXT FROM zxcv INTO @name, @salary;
END
CLOSE zxcv;
DEALLOCATE zxcv;
SELECT * FROM #Result1;