好吧,显然这不起作用。我收到“'=' 附近的语法错误”错误。是否可以在存储过程中多次更改变量的值?
与此示例类似:
DECLARE @columnCounter INT
SET @columnCounter = 0
DECLARE @columnName VARCHAR(255)
SET @columnName = 'A'
WHILE (@columnCounter < 4)
BEGIN
IF (@columnCounter == 1)
BEGIN
SET @columnName = 'B'
END
IF (@columnCounter == 2)
BEGIN
SET @columnName = 'C'
END
IF (@columnCounter == 3)
BEGIN
SET @columnName = 'D'
END
END
谢谢你。