[dba-SQLServer] Accees Grouping Vs SQL

artful at rogers.com artful at rogers.com
Tue Sep 26 13:29:45 CDT 2006


That will work for all future rows but not the existing rows. If there's an Identity column then it's trivial, but if not then you might consider adding one (even if only temporarily), since it will number the rows in the order they were added.

----- Original Message ----
From: Robert L. Stewart <rl_stewart at highstream.net>
To: dba-sqlserver at databaseadvisors.com
Sent: Tuesday, September 26, 2006 2:19:53 PM
Subject: Re: [dba-SQLServer] Accees Grouping Vs SQL

Actually, John, you should add a timestamp column to the data.
Then you can always get the last record added for any number of
duplicates.



At 12:00 PM 9/26/2006, you wrote:
>Message: 1
>Date: Mon, 25 Sep 2006 18:21:19 +0000
>From: "Mark A Matte" <markamatte at hotmail.com>
>Subject: Re: [dba-SQLServer] Accees Grouping Vs SQL
>To: dba-sqlserver at databaseadvisors.com
>Message-ID: <BAY126-F19A3ADDF703CC38BB4107BD2240 at phx.gbl>
>Content-Type: text/plain; format=flowed
>
>John,
>
>I just kinda lurk on the SQL list...just wading through trying to
>learn...and not sure if this could be a solution for you...but depending on
>what version of SQL you're using, one of the following may be useful:
>
>@@IDENTITY
>This is an intrinsic variable in SQL Server that contains the Id of the
>record that was last created on this connection, regardless of the table.
>IDENT_CURRENT('table')
>This function returns the ID of the record that was last created in the
>specified table.
>SCOPE_IDENTITY
>This variable contains the Id of the last record that was created within the
>current scope, regardless of the table.
>
>
>Good luck,
>
>Mark A. Matte
>
>
> >From: "John Skolits" <askolits at ot.com>
> >Reply-To: dba-sqlserver at databaseadvisors.com
> >To: <dba-sqlserver at databaseadvisors.com>
> >Subject: Re: [dba-SQLServer] Accees Grouping Vs SQL
> >Date: Mon, 25 Sep 2006 06:58:38 -0400
> >
> >Thanks for the responses.
> >
> >I really need Last since there are three records all with the same date and
> >I want to take the last one entered. There is no Increment field so no way
> >of knowing which is the last. With Access, I can be sure I have the right
> >record, but in SQL, I'm not sure. I wonder how the Access SQL call is
> >getting converted when it hits SQLServer when using First Or Last.
> >
> >I guess I can try to use the SQL tracer? I think that's what it's called,
> >been a while since I've used it. That might help figure it out.
> >
> >Thanks.
> >
> >John
> >


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com








More information about the dba-SQLServer mailing list