vendredi 29 juillet 2016

How to toggle between two values of concurrent table rows in sql

I have a table name [NavBar] with these columns:

Id [int]
Name [nvarchar]
DisplayOrder [int]

Sample data:

Id   Name   DisplayOrder
---------------------------
 100   Home        1
 101   Products    2
 103   Contact     3
 104   Career      4

How do I perform update operation to toggle between two rows DisplayOrder of two concurrent rows (order by Displayorder) ?

For example Contact = 4, Career = 3

Expected output:

100  Home      1
101  Products  2
102  Contact   4
103  Career    3

Input parameter: Id of one row only

Aucun commentaire:

Enregistrer un commentaire