Re: Reliable way to get ID of inserted record

2004-03-11 Thread Dwayne Cole
; > >#bar.lastID# > >- Original Message - >From: "Burns, John" <[EMAIL PROTECTED]> >Date: Thursday, March 11, 2004 11:02 am >Subject: Reliable way to get ID of inserted record > >> I know this came up last week or so, but I believe the answer came &

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Philip Arnold
> From: Ben Densmore > > Can scope_identity() be used to get identities in a query > such as the piece I have below? I tried using Select > Scope_Identity() AS emailID but my query kept complaining > that emailID didn't exist. You're within a SET NOCOUNT ON, so it won't be output to the query

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Jeff Garza
Densmore   To: CF-Talk   Sent: Thursday, March 11, 2004 1:52 PM   Subject: RE: Reliable way to get ID of inserted record   Can scope_identity() be used to get identities in a query such as the   piece I have below? I tried using Select Scope_Identity() AS emailID but   my query kept complaining

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Ben Densmore
Nevermind, I got it. Thanks, Ben -Original Message- From: Ben Densmore Sent: Thursday, March 11, 2004 3:53 PM To: CF-Talk Subject: RE: Reliable way to get ID of inserted record Can scope_identity() be used to get identities in a query such as the piece I have below? I tried using

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Ben Densmore
ax#" />,                      cfsqltype="CF_SQL_LONGVARCHAR"   value="#memento.CustWebsite#" /> ) Ben -Original Message- From: Jeff Garza [mailto:[EMAIL PROTECTED] Sent: Thursday, March 11, 2004 3:13 PM To: CF-

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Jeff Small
> I think that Rob nailed it in the posting right after yours.  This is only an issue where you have a trigger that inserts into a different table that has an IDENTITY field in it.  In that case, @@IDENTITY will return the inserted ID from the trigger rather than your your original insert.  Also, a

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Jeff Garza
ame.newID to CF... Cheers, Jeff Garza   - Original Message -   From: Jeff Small   To: CF-Talk   Sent: Thursday, March 11, 2004 11:48 AM   Subject: Re: Reliable way to get ID of inserted record   From: "Jeff Garza" <[EMAIL PROTECTED]>   To: "CF-Talk" <[EMAIL PROTE

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Kwang Suh
al Message - From: "Burns, John" <[EMAIL PROTECTED]> Date: Thursday, March 11, 2004 11:02 am Subject: Reliable way to get ID of inserted record > I know this came up last week or so, but I believe the answer came > for a > mySQL database.  I need a way in MS SQL to get th

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Rob
On Thu, 2004-03-11 at 10:51, Burns, John wrote: > But at the point where it does flip around, when you grabbed max() that > would no longer be the newest one right? Yes. That is correct. You might want to double check me on that behavoir (I dont have access to ms docs at the moment, but I did some

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Burns, John
But at the point where it does flip around, when you grabbed max() that would no longer be the newest one right? John -Original Message- From: Rob [mailto:[EMAIL PROTECTED] Sent: Thursday, March 11, 2004 1:33 PM To: CF-Talk Subject: RE: Reliable way to get ID of inserted record On Thu

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Rob
btw scope_identity() is not supported in SqlServer 7. -- Rob <[EMAIL PROTECTED]> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Rob
On Thu, 2004-03-11 at 10:35, Jeff Garza wrote: > Be carefull using @@IDENTITY, as it can return erroneous information (especially if your tables have triggers associated with them).  If you are using SQL Server 2000, use the SCOPE_IDENTITY() function instead of @@IDENTITY. It doesnt return erroneo

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Jeff Small
From: "Jeff Garza" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Thursday, March 11, 2004 1:35 PM Subject: Re: Reliable way to get ID of inserted record > Be carefull using @@IDENTITY, as it can return erroneous information (especially if your t

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Jeff Garza
: CF-Talk   Sent: Thursday, March 11, 2004 11:32 AM   Subject: RE: Reliable way to get ID of inserted record   On Thu, 2004-03-11 at 10:16, Burns, John wrote:   > But won't it eventually come back in and fill in some of those ones that   > were previously deleted?  As in your example, at

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Josh Remus
004 1:03 PM   To: CF-Talk   Subject: Reliable way to get ID of inserted record   I know this came up last week or so, but I believe the answer came for a   mySQL database.  I need a way in MS SQL to get the last inserted record   via CF.  I have a query inserting a row into the table with an  

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Rob
On Thu, 2004-03-11 at 10:16, Burns, John wrote: > But won't it eventually come back in and fill in some of those ones that > were previously deleted?  As in your example, at some point won't > another item get assigned the value of 4? MSSQL servers identity columns just keep going untill it they fi

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Barney Boisvert
Message- > From: Burns, John [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 11, 2004 10:03 AM > To: CF-Talk > Subject: Reliable way to get ID of inserted record > > I know this came up last week or so, but I believe the answer > came for a > mySQL database.  I need

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Burns, John
h 11, 2004 1:13 PM To: CF-Talk Subject: RE: Reliable way to get ID of inserted record As far as I know, whatever the maxid is at the time you will get next MaxID +1. However if you are deleting the last record and then adding a new one, In SQLServer you will get the following. ID    Value 1   

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Rob
On Thu, 2004-03-11 at 10:02, Burns, John wrote: > I know this came up last week or so, but I believe the answer came for a > mySQL database.  I need a way in MS SQL to get the last inserted record > via CF.  I have a query inserting a row into the table with an > auto-increment ID. I need to insert

Re: Reliable way to get ID of inserted record

2004-03-11 Thread Scott Weikert
Do your insert - and then do a select looking for a record matching several of the fields you just inserted. Doing a max(id) isn't 100% sure w/out transactional processing. But if you select on several fields that you *know* are unique... or at least, take the top record while sorting by the id

RE: Reliable way to get ID of inserted record

2004-03-11 Thread Eric Creese
    Value 1    a 2    b 3    c add a new record    ID    Value 1    a 2    b 3    c 5    d -Original Message- From: Burns, John [mailto:[EMAIL PROTECTED] Sent: Thursday, March 11, 2004 12:03 PM To: CF-Talk Subject: Reliable way to get ID of inserted record I know this came up last week or

Reliable way to get ID of inserted record

2004-03-11 Thread Burns, John
I know this came up last week or so, but I believe the answer came for a mySQL database.  I need a way in MS SQL to get the last inserted record via CF.  I have a query inserting a row into the table with an auto-increment ID. I need to insert that ID into a separate table in another query so I fir