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 |
|
HCLollo
Starting Member
49 Posts |
Posted - 2005-06-27 : 05:07:25
|
First of all hi to everyone! I've always been troubled with a little problem: is it possibleto have a code returned from an insert? I mean, let's imagineI have a very simple table like:IDNameWhen I do an insert, can I also have "something" return me theID it just entered? ID is of course an autoincrementing fieldused as the primary key.Thanks in advance,HCL |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-27 : 05:16:38
|
| Post sample data with expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-06-27 : 05:23:34
|
| Look up SCOPE_IDENTITY() and @@IDENTITY in BOL.SCOPE_IDENTITY() is the preferred method.rockmoose |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-27 : 05:36:15
|
| and also this oneSelect IDENT_CURRENT('tableName') will return the Id just enteredMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|