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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-02-20 : 08:17:36
|
| Arkadiy writes "Why @@indentity returns NULL after inserting new row?" |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-02-20 : 08:36:59
|
| post your code hereand its better to user scope_identity() function, see books online |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-20 : 09:10:05
|
| Does your table have identity column?Also that should be @@identity and not @@indentityMadhivananFailing to plan is Planning to fail |
 |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2006-02-20 : 09:12:56
|
Ensure you actually have an identity column in the table inserted, as well....set nocount oncreate table ##testidentity(i int)insert into ##testidentity (i) values (1)select @@identityselect * from ##testidentitycreate table ##testidentity2(uid int identity (1,1),i int)insert into ##testidentity2 (i) values (1)select @@identityselect * from ##testidentity2--RESULT ---------------------------------------- NULLi ----------- 1 ---------------------------------------- 1uid i ----------- ----------- 1 1 *##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2006-02-20 : 09:13:47
|
| lol - nice x-post eh Madhivanan? *##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-21 : 00:32:56
|
I think I was faster than you MadhivananFailing to plan is Planning to fail |
 |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2006-02-21 : 03:27:05
|
| yeah... you were faster, but I had an example :-)*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
|
|
|
|