Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 254.3k

How to update Identity Column from ROW_NUMBER in sql server

Apr 11 2014 8:07 AM
Hello,
How to update Identity Column from ROW_NUMBER in sql server 2008?

I am using this query for update but it's getting error:-
Cannot update identity column 'SNO'
set IDENTITY_INSERT tableSalesQuotation ON
update tableSalesQuotation
set
SNO=SubQuery.SNO
from
(SELECT Row_Number() OVER (ORDER BY SNO) as SNO
FROM tableSalesQuotation
) SubQuery
set IDENTITY_INSERT tableSalesQuotation OFF
please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer 

Answers (2)