Hello Everyone! In this article, we want to discuss about a nice function of adding value of every row to the next in SQL Server. Before we get started, if you want to know about use multiple column with “Not In” , please go through the following article: SQL: Can you use multiple columns for NOT IN.

Some time we need to select data with auto-generated sequence “Serial No” from table. It may have auto-generated column in you table. But when you select data with some condition, the column are may not be sequential. Then what you do?? It’s very simple to generated auto-sequential number with “ROW_NUMBER()“.

Please see the table structure first:

2014_10_27_10_52_26_Microsoft_SQL_Server_Management_Studio

adding value of every row to the next

Leave a Comment