Click here to Skip to main content
15,887,350 members
Home / Discussions / Database
   

Database

 
AnswerRe: Transaction , rollback ..??? Pin
Elina Blank22-Oct-07 8:07
sitebuilderElina Blank22-Oct-07 8:07 
QuestionSearch Engine Pin
Sandep H S21-Oct-07 21:22
Sandep H S21-Oct-07 21:22 
AnswerRe: Search Engine Pin
Abhijit Jana22-Oct-07 6:41
professionalAbhijit Jana22-Oct-07 6:41 
Questionselect last insert ID Pin
briogene21-Oct-07 21:20
briogene21-Oct-07 21:20 
AnswerRe: select last insert ID Pin
Aavesh Agarwal21-Oct-07 21:26
Aavesh Agarwal21-Oct-07 21:26 
GeneralRe: select last insert ID Pin
briogene21-Oct-07 22:32
briogene21-Oct-07 22:32 
GeneralRe: select last insert ID Pin
Aavesh Agarwal22-Oct-07 0:45
Aavesh Agarwal22-Oct-07 0:45 
GeneralRe: select last insert ID Pin
Pete O'Hanlon22-Oct-07 1:44
mvePete O'Hanlon22-Oct-07 1:44 
You really shouldn't do either of these, as they are both pretty bad practice. If you do a select on @@identity, you get the last inserted identity column regardless of scope. So, suppose you insert a record into your table and there is a trigger behind there that inserts into another table with an identity column on it, @@identity returns the id of the trigger insert and not the main table.

SELECT max(id) only works if there aren't multiple people posting into your tables at the same time.

The simple solution is to use:
SELECT @ID = SCOPE_IDENTITY()
This returns the identity of the inserted item on the main table, even if you have lots and lots of trigger inserts going on.

Deja View - the feeling that you've seen this post before.

AnswerRe: select last insert ID [modified] Pin
Chetan Patel21-Oct-07 23:25
Chetan Patel21-Oct-07 23:25 
QuestionHow to access network file using SQL Server 2000 Pin
Kumaran21cen21-Oct-07 21:04
Kumaran21cen21-Oct-07 21:04 
AnswerRe: How to access network file using SQL Server 2000 Pin
Ghazi H. Wadi3-Nov-07 23:19
Ghazi H. Wadi3-Nov-07 23:19 
QuestionSQL to return only first few records? Pin
jensenx21-Oct-07 17:50
jensenx21-Oct-07 17:50 
AnswerRe: SQL to return only first few records? Pin
N a v a n e e t h21-Oct-07 18:38
N a v a n e e t h21-Oct-07 18:38 
GeneralRe: SQL to return only first few records? Pin
jensenx21-Oct-07 21:10
jensenx21-Oct-07 21:10 
GeneralRe: SQL to return only first few records? [modified] Pin
GuyThiebaut22-Oct-07 1:28
professionalGuyThiebaut22-Oct-07 1:28 
GeneralRe: SQL to return only first few records? Pin
Pete O'Hanlon22-Oct-07 1:48
mvePete O'Hanlon22-Oct-07 1:48 
QuestionSecurity - Stored Procedure - Views - Tables Pin
DotNetWWW20-Oct-07 4:38
DotNetWWW20-Oct-07 4:38 
AnswerRe: Security - Stored Procedure - Views - Tables Pin
Colin Angus Mackay21-Oct-07 13:21
Colin Angus Mackay21-Oct-07 13:21 
QuestionType mismatch error for date field (MS ACCESS) Pin
Trav120-Oct-07 3:00
Trav120-Oct-07 3:00 
AnswerRe: Type mismatch error for date field (MS ACCESS) Pin
Blue_Boy21-Oct-07 9:27
Blue_Boy21-Oct-07 9:27 
QuestionAmbiguous column name 'Primary_ID'. whats wrong?? Pin
Vimalsoft(Pty) Ltd18-Oct-07 22:59
professionalVimalsoft(Pty) Ltd18-Oct-07 22:59 
AnswerRe: Ambiguous column name 'Primary_ID'. whats wrong?? Pin
GuyThiebaut18-Oct-07 23:05
professionalGuyThiebaut18-Oct-07 23:05 
AnswerRe: Ambiguous column name 'Primary_ID'. whats wrong?? Pin
Colin Angus Mackay18-Oct-07 23:05
Colin Angus Mackay18-Oct-07 23:05 
GeneralRe: Ambiguous column name 'Primary_ID'. whats wrong?? Pin
Vimalsoft(Pty) Ltd18-Oct-07 23:10
professionalVimalsoft(Pty) Ltd18-Oct-07 23:10 
GeneralRe: Ambiguous column name 'Primary_ID'. whats wrong?? Pin
Colin Angus Mackay18-Oct-07 23:21
Colin Angus Mackay18-Oct-07 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.