Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 3rd, 2006, 04:16 PM
Frank V Frank V is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Location: Toronto
Posts: 6 Frank V User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 51 sec
Reputation Power: 0
Most recent record

How can I query for the most recent record added to a table? Is there a way to relate the most recent record to CREATE TRIGGER ON INSERT?

Reply With Quote
  #2  
Old March 13th, 2006, 03:58 AM
manoher manoher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 manoher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 23 sec
Reputation Power: 0
In SQL Server you can do this by using IDENTITY property of the column

create table example(eid numeric(10,0) identity,ename varchar(10))

insert into example values('manohar')
insert into example values('deep')


we can get most recent record using following query

select * from example where eid =(select max(eid) from example)

Reply With Quote
  #3  
Old March 16th, 2006, 03:32 PM
Frank V Frank V is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Location: Toronto
Posts: 6 Frank V User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 51 sec
Reputation Power: 0
Manoher:

Thanks!

It's been a few days since I've checked the thread but had come up with the same solution in the meantime. Good to know I was on the right track.

Frank

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Most recent record


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway