Answered by:
change column auto increment in sql

Question
-
I have created table
create table student(rollno int,studname varchar(30),mark1 int,mark2 int,total as (mark1+mark2))
I have inserted 5 values with different rollno.Now i want to change that rollno as auto increment.
question:
1)I want sql query to change the rollno as auto increment.
2)previous rollno values also need to change.
by
Mukilan
Tuesday, May 29, 2012 6:41 AM
Answers
-
Hello Mukilan,
Similiar to my answer to your other post http://social.msdn.microsoft.com/Forums/de-DE/sqltools/thread/ae603ea9-a766-4a0d-8917-039eb6c2d285
You have to re-create the table.
Olaf Helper
* cogito ergo sum * errare humanum est * quote erat demonstrandum *
Wenn ich denke, ist das ein Fehler und das beweise ich täglich
Blog Xing- Marked as answer by itmukilan Tuesday, May 29, 2012 9:09 AM
- Unmarked as answer by itmukilan Tuesday, May 29, 2012 9:10 AM
- Marked as answer by itmukilan Tuesday, May 29, 2012 11:03 AM
- Unmarked as answer by itmukilan Tuesday, May 29, 2012 11:03 AM
- Marked as answer by itmukilan Tuesday, May 29, 2012 11:04 AM
Tuesday, May 29, 2012 6:57 AM
All replies
-
Hello Mukilan,
Similiar to my answer to your other post http://social.msdn.microsoft.com/Forums/de-DE/sqltools/thread/ae603ea9-a766-4a0d-8917-039eb6c2d285
You have to re-create the table.
Olaf Helper
* cogito ergo sum * errare humanum est * quote erat demonstrandum *
Wenn ich denke, ist das ein Fehler und das beweise ich täglich
Blog Xing- Marked as answer by itmukilan Tuesday, May 29, 2012 9:09 AM
- Unmarked as answer by itmukilan Tuesday, May 29, 2012 9:10 AM
- Marked as answer by itmukilan Tuesday, May 29, 2012 11:03 AM
- Unmarked as answer by itmukilan Tuesday, May 29, 2012 11:03 AM
- Marked as answer by itmukilan Tuesday, May 29, 2012 11:04 AM
Tuesday, May 29, 2012 6:57 AM -
I need query to alter column as auto increment column in sql
- Edited by itmukilan Tuesday, May 29, 2012 8:47 AM
Tuesday, May 29, 2012 7:05 AM -
Hi,
Create a new column with identity and drop the existing column.
ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you
Tuesday, May 29, 2012 11:10 AM -
I need query to alter column as auto increment column in sql
See ALTER TABLE, it's not possible to change a column to IDENTITY afterwards, you eigher have to add a new column with IDENTITY property or you have to recreate the table.
Olaf Helper
* cogito ergo sum * errare humanum est * quote erat demonstrandum *
Wenn ich denke, ist das ein Fehler und das beweise ich täglich
Blog XingTuesday, May 29, 2012 11:16 AM