Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nickjack
Starting Member
34 Posts |
Posted - 2008-11-14 : 02:32:26
|
| Hi i have a table in which there are 4 columnsID QuestionNo QuestionName QuestionValue1 Q001 h1 12 Q002 h2 2Column 2(Question) Get its value from ID and which is auto incremented?Now if i delete Q002 and insert value then the QuestionNumber comesQ003 not Q002? Any Help? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-14 : 02:40:54
|
| that how identity value increments. but why should you be concerned about this? the records will still be in sequence. its just that they will have gaps due to deletion.If you want them in sequence anyway and if you're using sql 2005, then use row_number() to generate sequence. |
 |
|
|
nickjack
Starting Member
34 Posts |
Posted - 2008-11-14 : 02:58:42
|
| no i am working on Sql Server 2000any sample code? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-14 : 04:22:17
|
Or use DBCC CHECKIDENT ? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
nickjack
Starting Member
34 Posts |
Posted - 2008-11-15 : 01:59:05
|
| This is the command to reset the counter? any other solution? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-15 : 04:44:52
|
quote: Originally posted by nickjack This is the command to reset the counter? any other solution?
use a temporary table with identity column. populate it with new records. then add maximum value of identity column from yourtable to each of these records to get new value. |
 |
|
|
|
|
|