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 |
|
SDC
Starting Member
3 Posts |
Posted - 2010-01-20 : 08:17:43
|
| how can I find the current value of a auto increment field in sql server 2008.I used max function but there are some limitations.Suppose I delete two rows. then if I use MAX() function it will show the max value of the the field, not the deleted rows value(it's lost). Now I want the new value that is generated.any help Plz.Thanks. |
|
|
svicky9
Posting Yak Master
232 Posts |
|
|
SDC
Starting Member
3 Posts |
Posted - 2010-01-20 : 08:42:27
|
| I used IDENT_CURRENT() .Then I increment the value by 1 to find the value that will be used if I insert a new row. OK that will solve my problem. ThanksBut May I know why I shall use use SET NOCOUNT ON |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-20 : 13:15:15
|
| You are not able to find what value will be given to a row that you are about to insert. Another user may make an INSERT just after you check IDENT_CURRENT() and before your INSERT happens.What you can find is the identity value that your row was given immediately after you insert it by checking "scope_identity()""But May I know why I shall useuse SET NOCOUNT ON"I can't see that that is relevant to your question, I'm afraid. Maybe divyaram can clarify? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-04 : 04:39:34
|
quote: Originally posted by divyaram use SET NOCOUNT ONRegards,Divya
Some of your recent answers add no value to the questionsDid you read the questions properly?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|