尝试如下...它会帮助你...
以逗号分隔传递您的表名...
DECLARE @test varchar(max);
Declare @Count int;
DECLARE @intFlag INT
SET @intFlag = 1
set @test = '#temp,#temp1,#temp2,#temp3'; --Table Names Separate by Commas
set @test = Replace(@test, ',', '.')
select @Count = len(@test) - len(replace(@test, '.', ''))
WHILE (@intFlag <= @Count + 1)
BEGIN
Declare @tablename as varchar(100)
Declare @sqlquery as varchar(5000)
Select @tablename = ParseName(@test, @intFlag )
SET @sqlquery = @sqlquery + 'UPDATE ' + @tablename
SET @sqlquery = @sqlquery + 'SET fk = (CASE fk '
SET @sqlquery = @sqlquery + 'WHEN 1 THEN 15 '
SET @sqlquery = @sqlquery + 'WHEN 2 THEN 16 '
SET @sqlquery = @sqlquery + 'WHEN 3 THEN 17 '
SET @sqlquery = @sqlquery + 'WHEN 4 THEN 11 '
SET @sqlquery = @sqlquery + 'WHEN 5 THEN 12 '
SET @sqlquery = @sqlquery + 'WHEN 6 THEN 13 '
SET @sqlquery = @sqlquery + 'WHEN 7 THEN 14 '
SET @sqlquery = @sqlquery + 'END) WHERE fk IN (1,2,3,4,5,6,7) UPDATE ' + @tablename + ' SET fk = fk - 10'
print @sqlquery
exec(@sqlquery)
SEt @intFlag = @intFlag + 1
END