I had a requirement where I need to update a field of every alternate rows of my SQL Server database table. After few trial, I came to below code snippet.
Update [UsersName] SET LookingForMe = 1 where (AutoId%2) = 0
is my table nameAutoId
is the auto increment column of the database table.LookingForMe
is the column name I wanted to update.
The trick here is that I am getting MOD of AutoId column value and if its 0, I am going to update that row column.
Hope this will be helpful for someone.