Sunday, May 15, 2011

Testing only

I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool. I am testing this tool.
W.Blogger Posting with W.Blogger. !

Tuesday, March 1, 2011

SQL Server : What is scheduled next 2 hours?

Problem:
Often, we come up with a situation where we want to know what is scheduled in SQL Agent for next 2 hrs or 24 hrs. I got a nice script which can be used to find out this.

Solution:

DECLARE @HowManyHoursAhead int

Set @HowManyHoursAhead = 2; -- <-- Change the hour here.

WITH OurJobs AS (
SELECT job.job_id, job.[name]
, CASE job.[description] WHEN 'No description available.' THEN NULL ELSE job.description END AS Description
, job.date_modified
, CASE sched.next_run_date
WHEN 0 THEN 'Never'
ELSE
CONVERT(varchar(10), CONVERT(smalldatetime, CAST(sched.next_run_date as varchar), 120), 120)+' '+
RIGHT('0'+CAST((sched.next_run_time/10000) AS VARCHAR), 2)+':'+
RIGHT('0'+CAST((sched.next_run_time-((sched.next_run_time/10000)*10000))/100 AS VARCHAR), 2)+':'+
RIGHT('0'+CAST((sched.next_run_time-((sched.next_run_time/10000)*10000)-((sched.next_run_time-((sched.next_run_time/10000)*10000))/100*100)) AS VARCHAR), 2)
END AS NextRunDateTime
, (
SELECT CASE last_run_date
WHEN 0 THEN 'Never'
ELSE
CONVERT(varchar(10), CONVERT(smalldatetime, CAST(last_run_date as varchar), 120), 120)+' '+
RIGHT('0'+CAST((last_run_time/10000) AS VARCHAR), 2)+':'+
RIGHT('0'+CAST((last_run_time-((last_run_time/10000)*10000))/100 AS VARCHAR), 2)+':'+
RIGHT('0'+CAST((last_run_time-((last_run_time/10000)*10000)-((last_run_time-((last_run_time/10000)*10000))/100*100)) AS VARCHAR), 2)
END AS LastRunDateTime
FROM msdb.dbo.sysjobsteps
WHERE job_id = job.job_id AND step_id = (
SELECT MAX(step_id)
FROM msdb.dbo.sysjobsteps
WHERE job_id = job.job_id
)
) as LastSuccessfulExecution
FROM msdb.dbo.sysjobs job JOIN msdb.dbo.sysjobschedules sched
ON sched.job_id = job.job_id
WHERE job.enabled = 1 -- remove this if you wish to return all jobs
AND sched.next_run_date > 0
)
SELECT * FROM OurJobs
WHERE DATEDIFF(hh, GETDATE(), NextRunDateTime) <= @HowManyHoursAhead
GO

Sunday, February 27, 2011

Delay in Hibernation

Recently I had a problem that after playing with several components in my laptop, Hibernate became damn slow. It was so slow that it took nearly 15 mins to complete Hibernate. This delay was sometimes too much that my battery used to go off in the middle. Not sure which part of experiment did this. I remember that I installed some patches which might have caused the problem.

Problem:
Delay in Hibernation in Windows based systems (Windows-XP, Windows-2003, Windows Vista)

Solution:
I got this solution over a forum. The person gave me below tip which worked perfectly -
1. If you have installed Windows in C:\ Drive, right click C: drive and goto Properties.
2. Goto Hardware Tab.

3. You might see Disk Drive, CD-Rom and other drivers. click the Disk Drive and click Properties button.
4. On Properties message-box. Click Policies tab.

5. Enable 'Write Catching on Disk'.

6. Click all OKs to close all message-boxes.
7. Hibernate the system to test it.

I got my problem solved, Did you..