[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to restrict Select statement results to last 5 minutes?

Posted on 2011-10-27
8
Medium Priority
?
434 Views
Last Modified: 2012-05-12
Using SQL Server  - I have the following basic Select statement:

SELECT ReportInstanceID

FROM dbo.ReportInstance

WHERE Status = 'FAILED'

I am only interested in the results within the last 5 minutes not the entire result set...

Any guidance would be appreciated!
0
Comment
Question by:newtontech4
  • 3
  • 2
6 Comments
 
LVL 21

Accepted Solution

by:
JestersGrind earned 2000 total points
ID: 37038081
Is the time that the record is inserted into that table captured?  If there isn't a date time associated with an instance of a report you may be out of luck.  You could add an additional column, CreatedOn DATETIME with a DEFAULT of GetDate().  That should have minimal impact on existing code and give a date/time to filter by.

Greg

0
 

Author Comment

by:newtontech4
ID: 37038205
Thank you - in event the time the record is inserted into the table is captured would this be proper SQL syntax?

(sorry by no means a SQL expert..)

SELECT ReportInstanceID FROM dbo.ReportInstance WHERE Status = FAILED AND datefield >= dateadd(minute,-60,getdate())

0
 
LVL 21

Assisted Solution

by:JestersGrind
JestersGrind earned 2000 total points
ID: 37038376
That would get everything within the last hour.  For the last 5 minutes, just change -60 to -5.

Greg

0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 

Author Comment

by:newtontech4
ID: 37041714
I've requested that this question be closed as follows:

Accepted answer: 0 points for newtontech4's comment http:/Q_27418345.html#37038205

for the following reason:

solution provided...
0
 

Author Comment

by:newtontech4
ID: 37038598
hello - my apologies I accidentally accepted my response as the solution.  All credit should go to JestersGrind - 500 points.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37041715
The author made a mistake and needs to award points to JestersGrind.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question