游标中未声明变量!
set ANSI_NULLS ON
go
set QUOTED_IDENTIFIER ON
go
ALTER proc tihuanDptId
@num1 decimal,
@num2 decimal
AS
declare @table1 varchar(4000)
declare tihuanDptId cursor for
select o.[name] from sysobjects o , syscolumns c
where 1=1 and o.id = c.id and c.[name]= 'DptId' and o.userstat=1
open tihuanDptId
fetch next from tihuanDptId into @table1
while @@fetch_status=0
begin
update @table1 set DptId=@num2 where DptId=@num1
fetch next from tihuanDptId into @table1
end
close tihuanDptId
deallocate tihuanDptId
GO
消息 1087,级别 15,状态 2,过程 tihuanDptId,第 17 行
必须声明表变量 "@table1"。