代码
SET NOCOUNT ON

begin tran

DECLARE @newsid varchar(80)
DECLARE @ishaveAnnex varchar(100)

DECLARE vendor_cursor CURSOR FOR
SELECT [newsid] FROM [News]

OPEN vendor_cursor
FETCH NEXT FROM vendor_cursor INTO @newsid

WHILE @@FETCH_STATUS = 0
BEGIN

select @ishaveAnnex =ishaveAnnex from News where newsid = @newsid

if (@ishaveAnnex = '1')
begin
update News set ishaveAnnex = '0' where newsid = @newsid
end
else if (@ishaveAnnex = '0')
begin
update News set ishaveAnnex = '1' where newsid = @newsid
end
FETCH NEXT FROM vendor_cursor INTO @newsid

END
CLOSE vendor_cursor
DEALLOCATE vendor_cursor
if @@error<>0
rollback tran
else
commit tran

 

相关文章:

  • 2021-08-09
  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2021-12-22
  • 2021-05-17
猜你喜欢
  • 2021-06-27
  • 2021-08-13
  • 2021-09-01
  • 2021-07-19
  • 2022-12-23
  • 2021-08-09
  • 2021-05-22
相关资源
相似解决方案