Thursday, January 6, 2011

Increment rownumbers

SET IDENTITY_INSERT USERS OFF
with cte as
(
select row_number()over(order by userid)Rid ,* from #TAB where userid > 1
)
--select id,9+userid USERID,username from cte WHERE  

update #TAB  set  #TAB.userid= 9+#TAB.userid from cte c where #TAB.userid >1

SET IDENTITY_INSERT USERS on

No comments:

Post a Comment