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.
Author |
Topic |
avitron2020
Starting Member
3 Posts |
Posted - 2015-02-25 : 20:24:13
|
I’m working on an existing database that has a table like the following:Table Name: account_infoidfirst_namelast_nameaccount_numberamountExample data:1, John, Smith, 1-271342, 600.002, Marty, Kent, 1-236342, 100.003, Bill, Jones, 1-174234, 350.00etc.I have another table that tracks when the ‘account_info‘ table above has been last updated:Table Name: account_update_historyidlast_updatedagent_who_updatedaccount_info_idExample data:1, 2015-02-04 04:23:43, Jill Beth, 22, 2015-02-03 12:27:14, Jill Beth, 23, 2015-02-01 14:31:32, Jill Beth, 24, 2015-02-03 23:43:52, Bob Smith, 15, 2015-02-01 06:23:42, Bob Smith, 1etc.The ‘account_update_history’ table can have many entries depending upon how many times the ‘account_info’ table has been updated. Where each of these rows points back to an 'account_info' row from the first tableMy question is, I want to pull data from the database daily but only if an ‘account_info’ row has been recently updated (like for instance, the last 24 hours). What’s the best way to do this efficiently? I have thousands of records to scan daily. |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2015-02-26 : 01:06:58
|
last_updated>=dateadd(hh,-24,getdate()) |
|
|
|
|
|
|
|