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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select record to last inserted in table

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2011-06-29 : 00:13:35
Dear Member

Following are my table structure

col1 col2 col3
item1 wt1 10/5/2011
item2 wt2 10/5/2011
item3 wt3 10/5/2011
item4 wt4 10/5/2011
item1 wt1 9/5/2011
item2 wt2 9/5/2011
item3 wt3 9/5/2011
item4 wt4 9/5/2011
item1 wt1 8/5/2011
item2 wt2 8/5/2011
item3 wt3 8/5/2011
item4 wt4 8/5/2011
This table i have insert a daily record with current date.i have write a select query to found a record on inserted last date in table.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-06-29 : 00:49:35
SELECT TOP(1) * FROM dbo.Table1 ORDER BY Col3 DESC
SELECT TOP(1) WITH TIES * FROM dbo.Table1 ORDER BY Col3 DESC


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -