I am trying to create a primary key for my table. Primary key would be the row number. First row should have seq_no 1, row n should have sequence number n and so on
Emp_demo2
emp_id emp_name emp_sal_K emp_manager 1 Ali 200 2 20 Zaid 770 4 and so on
Query to add and update columns
Alter table emp_demo2 Add seq_no int Update emp_demo2 set seq_no = row_number
Error
Invalid column name ‘seq_no’.
Advertisement
Answer
Use this line instead of add and update
Alter table emp_demo2 add seq_no int identity not null;