交换一个表中两个字段的值

declare mycur cursor
  for( select RowGuid,PositionX,PositionY FROM [LY_BIMPM_RoadBridge].[dbo].[SpacePositionCategory] WHERE PositionX>0 AND PositionY>0)

  OPEN mycur;
  declare @rowguid varchar(50),@tempX FLOAT,@tempY FLOAT
  fetch next from mycur into @rowguid,@tempX,@tempY
  while(@@FETCH_STATUS=0)
	begin 
	update [LY_BIMPM_RoadBridge].[dbo].[SpacePositionCategory] set PositionX = @tempY,PositionY = @tempX where RowGuid = @rowguid
	fetch next from mycur into @rowguid,@tempX,@tempY
	end
  close mycur

  

posted @ 2016-12-30 11:39  HongEgg  阅读(279)  评论(0编辑  收藏  举报