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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Selecting Most recent row

Author  Topic 

velvettiger
Posting Yak Master

115 Posts

Posted - 2010-09-15 : 13:56:51
Hi there,

I have a table that have many different rows and would like to select the most recently updated row. Any ideas.

Thanks,
Amanda

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 14:00:02
Do you have a column to indicate when it was updated?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2010-09-15 : 14:27:22
quote:
Originally posted by velvettiger

I have a table that have many different rows and would like to select the most recently updated row.


That question makes sense for a magnetic tape file and makes no sense for a table. SQL is a set-oriented language and rows are updated AS ENTIRE SETS, ALL AT ONCE.

Also, the rows in a table all have the same structure; you cannot have "many different rows" in a table.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-16 : 12:34:46
quote:
Originally posted by velvettiger

Hi there,

I have a table that have many different rows and would like to select the most recently updated row. Any ideas.

Thanks,
Amanda


are you using sql 2008 and is there by any chance change tracking enabled?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -