2
Answers

How to update Identity Column from ROW_NUMBER in sql server

Ankit Agarwal

Ankit Agarwal

10y
1.9k
1
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)