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 |
|
norty911
Starting Member
41 Posts |
Posted - 2007-07-24 : 04:45:29
|
| hey guys, how could you get the primary key field of a record you have just inserted into a table?Many thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-24 : 05:07:28
|
| what is the datatype of the primary key?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-24 : 05:09:49
|
if you are using identity column you can use @@identity or scope_identity() KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
norty911
Starting Member
41 Posts |
Posted - 2007-07-24 : 05:38:41
|
| Thank you @@identity was exactly what I was looking for. Tell me are there any differences between @@identity and scope_identity()? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-24 : 05:41:04
|
Yes. Read the BOL for the detail answer KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-24 : 05:41:29
|
| books OnLine = sql server help explains the difference quite nicly._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-24 : 05:41:50
|
_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|
|