| Author |
Topic |
|
chiragvm
Yak Posting Veteran
65 Posts |
Posted - 2007-09-26 : 07:19:06
|
| hi to all i want to one select query witch is return me one number in my database one auto generate field i want to know what is the next auto generate number in next record?ex i will try in max + 1 but is not working when i delete last record in table 4 record 1,2,3,4so next record is 5 but i delete 4th record and tryso it return 4 instead of 5 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-26 : 07:24:11
|
Something very similar toDBCC CHECKIDENT(Table1, RESEED) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-26 : 08:30:51
|
| When you use identity column, you dont need max + 1 Use Scope_identity()MadhivananFailing to plan is Planning to fail |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-09-26 : 09:12:21
|
| i want to know what is the next auto generate number in next record?who cares what the NEXT one is? SQL SERVER is going to insert it, NOT you or the client application.Like Madhi said, Scope_identity() will return the id that was inserted (current ID).[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-26 : 09:16:53
|
Steady cowboy, the way I read it:The OP is asking the question that Madhi has answered, and not the one YOU think the OP is asking |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-09-26 : 12:45:08
|
Funny Kristen, I thought we answered the same question. I just interjected a question of "Who cares what the max is" since it does not matter in the least. [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-26 : 15:06:58
|
| "since it does not matter in the least"I think it matters a lot if English is the OP's second language and what they mean is "What is the ID for the record I inserted" but phrased it as "What is the ID for the record I am just about to insert".Jumping to conclusions is a bit easy in here, and I'd like to just remind folk that a) English may not be the first language of posters and b) this particular forum is "New to SQL Server"Personally, my generous nature does not apply to the obvious Twits and Arrogant people we get here, nor those abusing the generous nature of all those posting and giving their time for free by wanting their Homework answered with no effort on their part, etc.But can I suggest a "Take a deep breath first" stance please?Kristen |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-09-27 : 07:40:04
|
Nope. I usually post before the first cup of coffee. That makes for shortness of patience [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|