id name ischeck
1 jack 1
2 tony 2
3 amanda 4
4 xiao 5
5 ming 6
6 tao 3
这样的更新语句怎么写?求各位帮忙!答者给分!谢谢!
分享到:更多
------解决方案-------------------- insert into table
select id,name,max(id)+1
from table
CREATE Proc spprod
@Uid int,
@name varchar(255),
@NewOrderIndex smallint
as
Declare @OrderIndex int
Select @OrderIndex=OrderIndex from DDASCommand where Uid=@Uid
if(@OrderIndex<@NewOrderIndex)
Begin
Update table set check=check-1 where check>@OrderIndex and check<=@NewOrderIndex
Update table set name=@name,check=@NewOrderIndex where id=@id
End
Else
Begin
Update table set check=OrderIndex+1 where check<@OrderIndex and check>=@NewOrderIndex
Update table set check=@NewOrderIndex,name=@name where id=@id
End ------解决方案--------------------