Reputation: 10542
Hey all i have an app that runs everyday to gather updates for a table in my SQL Server 2008 database. I also have a front end website that displays those stats for a user.
I am trying to figure out away to inform the user, once they log into the website, that the db is currently being updated.
The code I have so far is:
SELECT *
FROM dataLog
WHERE theDT >= '2012-12-05 00:00:00'
AND theDT <= '2012-12-05 23:59:59'
AND theType <> 'Completed'
When the app starts it writes this record to the dataLog
table:
id | theDT | theMsg | theFunction | theType
130 2012-12-05 09:17:13.000 Beginning Main Starting
And when its finished it writes:
id | theDT | theMsg | theFunction | theType
137 2012-12-05 09:47:13.000 Ended Main Completed
I'm just not sure how to go about checking that as my code above shows it every time regardless if it has completed or not.
Upvotes: 0
Views: 94
Reputation: 4585
Sorry if this is too simple.
Select Top 1
*
From dataLog
Where theDate < GetDate()
Order By theDate DESC
Then your front end can display the current status and, if the status is Starting, display the "Updating: started at x" message, and if status is "Completed", display the "Update completed at x" message.
Upvotes: 0
Reputation: 9607
try this:
select max_dt, theType from
datalog d inner join
(SELECT max(theDt) as max_dt FROM dataLog) m
on d.theDt = m.max_dt
Upvotes: 1