i have a table with columns Name, StudentID
how do i update the studentID column on all of the student and increment them by 1
say original table is
name studentid
a 23
b 14
c 15
now i want to make it like this
name studentid
a 1
b 2
c 3
could anyone help than kyou

delete in sql
dsula
Frank N White
you could use dataadapter to update. However, the following 3 t-sql will also do the job:
alter table your_table add newid int identity
alter table your_table drop column studentid
sp_rename 'your_table.newid', 'studentid', 'COLUMN'
Riady
If you want to Incr StudentID by 1 why have you shown a wrong expected output. Is it something else that you try to convey.
-Ajeeth
rgalgon
good solution unless you have child tables (with foreign keys to studentid)
if so, suggest you have your FKs with cascade on update, and change the your_table.studentid in-place using a cursor