ifexists (select*from dbo.sysobjects where id =object_id(N'[dbo].[Department]') andOBJECTPROPERTY(id, N'IsUserTable') =1) droptable[dbo].[Department] GO CREATETABLE[dbo].[Department] ( [departID][int]IDENTITY (1, 1) NOTNULL , [departName][varchar] (32) COLLATE Chinese_PRC_CI_AS NOTNULL , [leagueID][int]NOTNULL , [visible][bit]NOTNULL , [sortDep][int]NOTNULL ) ON[PRIMARY] GO
存储过程代码
CREATEproc Dep_SetSort @ReturnValueint=0 output, @impactIDint, @depIDint, @operatevarchar(10)='Next' as if(@operate='Pre') begin --上移 update[Department]set sortDep=sortDep+1where departID=@impactID update[Department]set sortDep=sortDep-1where departID=@depID end if(@operate='Next') begin --下移 update[Department]set sortDep=sortDep-1where departID=@impactID update[Department]set sortDep=sortDep+1where departID=@depID end set@ReturnValue=1 GO