I have a table with more than 30000 rows.
I need to update the table using a SQL query which required this type of output.
Initial Table :-
1 , 1 , a ,b
2 , 1 , b ,c
3 , 1 , c ,d
....
50 , 1 , b ,n
51 , 2 , f ,y
52 , 2 , g ,o
53 , 2 , t ,t
....
....
100, 2 , f, h
Output should be like this :-
1 , 1 , a ,b
2 , 1 , b ,c
3 , 1 , f ,r(new row)
4 , 1 , c ,d
....
51 , 1 , b ,n
52 , 2 , f ,y
53 , 2 , g ,o
54 , 2 , r ,t(new row)
55 , 2 , t ,t
....
....
102, 2 , f, h
So basically first column (primary key) which is auto incrementing should be changed while we enter data based on second column (some type of question Id).
I already seen and referred this question(SQL How to insert a new row in the middle of the table , MySQL syntax for inserting a new row in middle rows?, Insert data in the middle of any table) but they provide solution for smaller tables while I have a table which contains more than 30000 rows.
Can anyone give me any suggestion?
FYI :- I use Microsoft SQL Server.