Create Procedure Community_CommunitiesMovedown (@communityid Int) asdeclare @SortorderCurrent INTDECLARE @SortordRabove Int
- get current sort orderrslect @SortorderCurrent = Community_SortorderFrom Community_Communitieswhere Community_ID = @communityID
- Get Sort ORDER for Section Aboveselect @SortordRabove = min (Community_Sortorder) from Community_Communitieswhere Community_Sortorder> @SortorderCurrent
- IF NO ROW ABOVE, EXITIF @SortordRabove is Null Return
- OtherWise, Switch Sort Ordersupdate Community_Communities Set Community_Sortorder = @SortorderCurrent Where Community_Sortorder = @SortordRabove
Update community_communities set community_sortorder = @SortordRabove where community_id = @communityID
GO ================================================== =====================
Create Procedure Community_CommunitiesMoveUp (@communityid Int) assdeclare @SortorderCurrent INTDDECLARE @SortorderBelow Int
- get current sort orderrslect @SortorderCurrent = Community_SortorderFrom Community_Communitieswhere Community_ID = @communityID
- Get Sort Order for section Belowselect @SortorderBelow = max (Community_Sortorder) from Community_Communitieswhere Community_Sortorder <@SortorderCurrent
- if no row brows, exitif @Sortorderbelow is Null Return
- Otherwise, switch sort ordersUPDATE Community_Communities SET community_sortOrder = @sortOrderCurrent WHERE community_sortOrder = @sortOrderBelowUPDATE Community_Communities SET community_sortOrder = @sortOrderBelow WHERE community_ID = @communityID
Go