<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Time Delay While Running T-SQL Query &#8211; WAITFOR Introduction</title>
	<atom:link href="http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 04:35:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: RobboFett</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-198024</link>
		<dc:creator><![CDATA[RobboFett]]></dc:creator>
		<pubDate>Thu, 17 Nov 2011 23:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-198024</guid>
		<description><![CDATA[I have used WAITFOR to allow the RAM held by SQL Server to be released overnight, without it the upper limit is reinstated before the server has time to release it and it doesn&#039;t drop down.

EXEC sys.sp_configure N&#039;show advanced options&#039;, N&#039;1&#039;

RECONFIGURE WITH OVERRIDE

GO
EXEC sys.sp_configure N&#039;max server memory (MB)&#039;, N&#039;4000&#039;

RECONFIGURE WITH OVERRIDE

GO

WAITFOR DELAY &#039;00:01:00&#039;

EXEC sys.sp_configure N&#039;max server memory (MB)&#039;, N&#039;10000&#039;

RECONFIGURE WITH OVERRIDE

GO

EXEC sys.sp_configure N&#039;show advanced options&#039;, N&#039;0&#039;

RECONFIGURE WITH OVERRIDE

GO]]></description>
		<content:encoded><![CDATA[<p>I have used WAITFOR to allow the RAM held by SQL Server to be released overnight, without it the upper limit is reinstated before the server has time to release it and it doesn&#8217;t drop down.</p>
<p>EXEC sys.sp_configure N&#8217;show advanced options&#8217;, N&#8217;1&#8242;</p>
<p>RECONFIGURE WITH OVERRIDE</p>
<p>GO<br />
EXEC sys.sp_configure N&#8217;max server memory (MB)&#8217;, N&#8217;4000&#8242;</p>
<p>RECONFIGURE WITH OVERRIDE</p>
<p>GO</p>
<p>WAITFOR DELAY &#8217;00:01:00&#8242;</p>
<p>EXEC sys.sp_configure N&#8217;max server memory (MB)&#8217;, N&#8217;10000&#8242;</p>
<p>RECONFIGURE WITH OVERRIDE</p>
<p>GO</p>
<p>EXEC sys.sp_configure N&#8217;show advanced options&#8217;, N&#8217;0&#8242;</p>
<p>RECONFIGURE WITH OVERRIDE</p>
<p>GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rozwel</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-170303</link>
		<dc:creator><![CDATA[Rozwel]]></dc:creator>
		<pubDate>Wed, 21 Sep 2011 12:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-170303</guid>
		<description><![CDATA[The scenario where we use WAITFOR TIME is when we have Job A trigger Job B.  Job A can run at any time with minimal user impact, and has a highly variable start time and duration.  Job B tends to run quickly but has an extremely high user impact if it runs during business hours.  The “normal” hand off time from A to B should fall between 3 and 5AM, but sometimes it is late.  So we added a step at the beginning of Job B to check the current time, and if it is after the safe time for Job B to complete before the start of the business day, it uses WAITFOR to pause the job and process the data in the evening instead.]]></description>
		<content:encoded><![CDATA[<p>The scenario where we use WAITFOR TIME is when we have Job A trigger Job B.  Job A can run at any time with minimal user impact, and has a highly variable start time and duration.  Job B tends to run quickly but has an extremely high user impact if it runs during business hours.  The “normal” hand off time from A to B should fall between 3 and 5AM, but sometimes it is late.  So we added a step at the beginning of Job B to check the current time, and if it is after the safe time for Job B to complete before the start of the business day, it uses WAITFOR to pause the job and process the data in the evening instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorge Luis</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-150207</link>
		<dc:creator><![CDATA[Jorge Luis]]></dc:creator>
		<pubDate>Sat, 23 Jul 2011 14:06:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-150207</guid>
		<description><![CDATA[WOW... I had no idea whatsoever about this T-SQL feature!

It definitely made up my day!  I am currently using this feature to restart programmatically a SQL Job based on certain conditions.

Why? Well basically I am facing random hangs during nightly execution of my ETL packages. Every night we extract data from a legacy database called ADABAS. We have to use a third party software called CONNX to retrieve data from it in a relational format. The issue has been rooted to CONNX and they are asking us to upgrade to the latest version before troubleshooting anything. That is something that won&#039;t happen anytime soon. Therefore, I have had to be creative and look for workarounds to get through with the hangs.

So I am using WAITFOR. Because these random hangs usually get solved by restarting the jobs. These jobs run @ 12:00 AM. So I have created specific jobs to monitor the other jobs at specific times and check if they are taking longer than usual. If they do, I stop the Jobs. This is where WAITFOR comes in. If you stop and restart a job programmatically, SQL will raise and error saying the job is still running... This is because the JOB hasn&#039;t been fully stopped yet when sp_start_job is triggered. Therefore needing WAITFOR in between those exec lines.]]></description>
		<content:encoded><![CDATA[<p>WOW&#8230; I had no idea whatsoever about this T-SQL feature!</p>
<p>It definitely made up my day!  I am currently using this feature to restart programmatically a SQL Job based on certain conditions.</p>
<p>Why? Well basically I am facing random hangs during nightly execution of my ETL packages. Every night we extract data from a legacy database called ADABAS. We have to use a third party software called CONNX to retrieve data from it in a relational format. The issue has been rooted to CONNX and they are asking us to upgrade to the latest version before troubleshooting anything. That is something that won&#8217;t happen anytime soon. Therefore, I have had to be creative and look for workarounds to get through with the hangs.</p>
<p>So I am using WAITFOR. Because these random hangs usually get solved by restarting the jobs. These jobs run @ 12:00 AM. So I have created specific jobs to monitor the other jobs at specific times and check if they are taking longer than usual. If they do, I stop the Jobs. This is where WAITFOR comes in. If you stop and restart a job programmatically, SQL will raise and error saying the job is still running&#8230; This is because the JOB hasn&#8217;t been fully stopped yet when sp_start_job is triggered. Therefore needing WAITFOR in between those exec lines.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iyappan Seeva</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-146399</link>
		<dc:creator><![CDATA[Iyappan Seeva]]></dc:creator>
		<pubDate>Wed, 06 Jul 2011 13:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-146399</guid>
		<description><![CDATA[can u tell where this waitfor is important pls tell me in practical basis]]></description>
		<content:encoded><![CDATA[<p>can u tell where this waitfor is important pls tell me in practical basis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parth Malhan</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-104517</link>
		<dc:creator><![CDATA[Parth Malhan]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 02:14:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-104517</guid>
		<description><![CDATA[if we schedule a database backup with waitfor clause
like

while 1=1
begin
   waitfor time &#039;17:36:30&#039;
   backup databse ......................................
end


does it requires the resources while it is waiting for the time or not.

will this reduce performance]]></description>
		<content:encoded><![CDATA[<p>if we schedule a database backup with waitfor clause<br />
like</p>
<p>while 1=1<br />
begin<br />
   waitfor time &#8217;17:36:30&#8242;<br />
   backup databse &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..<br />
end</p>
<p>does it requires the resources while it is waiting for the time or not.</p>
<p>will this reduce performance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mrinmoy</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-92527</link>
		<dc:creator><![CDATA[Mrinmoy]]></dc:creator>
		<pubDate>Wed, 13 Oct 2010 12:02:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-92527</guid>
		<description><![CDATA[WAITFOR ....
waits for a specified interval or time but displays the result of all the queries after the last query is executed.


I need the output of the first query as soon as it gets executed

Then wait for specified interval

execute the next query and display 2nd output]]></description>
		<content:encoded><![CDATA[<p>WAITFOR &#8230;.<br />
waits for a specified interval or time but displays the result of all the queries after the last query is executed.</p>
<p>I need the output of the first query as soon as it gets executed</p>
<p>Then wait for specified interval</p>
<p>execute the next query and display 2nd output</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Sline</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-53921</link>
		<dc:creator><![CDATA[Rick Sline]]></dc:creator>
		<pubDate>Tue, 21 Jul 2009 13:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-53921</guid>
		<description><![CDATA[Some years ago I could not get a job scheduled through the server (politics) and had to launch a mission critical application that was all in T-SQL every day at the later of:
1) 5am
2) when a particular record was written to a table each day.  On &quot;bad&#039; days this could be as late as 7 or 8am

I didn&#039;t want to keep hitting the server in a tight loop, so I&#039;d leave the SP running to fire at 5am to check for the record, I&#039;d then re-check every 10 minutes.  

As an aside, if &quot;the record&quot; wasn&#039;t in place by 6am I&#039;d normally be on the phone to the person responsible for that  process to see what the hold-up was.  for major delays I&#039;d cancel the job until I got the all-clear.]]></description>
		<content:encoded><![CDATA[<p>Some years ago I could not get a job scheduled through the server (politics) and had to launch a mission critical application that was all in T-SQL every day at the later of:<br />
1) 5am<br />
2) when a particular record was written to a table each day.  On &#8220;bad&#8217; days this could be as late as 7 or 8am</p>
<p>I didn&#8217;t want to keep hitting the server in a tight loop, so I&#8217;d leave the SP running to fire at 5am to check for the record, I&#8217;d then re-check every 10 minutes.  </p>
<p>As an aside, if &#8220;the record&#8221; wasn&#8217;t in place by 6am I&#8217;d normally be on the phone to the person responsible for that  process to see what the hold-up was.  for major delays I&#8217;d cancel the job until I got the all-clear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael oneill</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-45582</link>
		<dc:creator><![CDATA[michael oneill]]></dc:creator>
		<pubDate>Tue, 13 Jan 2009 16:33:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-45582</guid>
		<description><![CDATA[hi,
I use the WAITFOR command allot in DTS&#039;s while an External Application (WinRar) compacts Access MDB files that have just been created from SQL Views. Once the Delay has timed out I then publish the Zipped files to our website. The WAITFOR command saved me creating lots of different DTS or Batch files can kicking then off at different times.
Cheers Michael]]></description>
		<content:encoded><![CDATA[<p>hi,<br />
I use the WAITFOR command allot in DTS&#8217;s while an External Application (WinRar) compacts Access MDB files that have just been created from SQL Views. Once the Delay has timed out I then publish the Zipped files to our website. The WAITFOR command saved me creating lots of different DTS or Batch files can kicking then off at different times.<br />
Cheers Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dena</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-45406</link>
		<dc:creator><![CDATA[Dena]]></dc:creator>
		<pubDate>Tue, 06 Jan 2009 13:55:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-45406</guid>
		<description><![CDATA[We have the use for a waitfor due to our developers writing a process that returns a status code. We will give it 45 seconds, check the results and continue depending on the results.]]></description>
		<content:encoded><![CDATA[<p>We have the use for a waitfor due to our developers writing a process that returns a status code. We will give it 45 seconds, check the results and continue depending on the results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-45318</link>
		<dc:creator><![CDATA[Josh]]></dc:creator>
		<pubDate>Sat, 03 Jan 2009 21:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-45318</guid>
		<description><![CDATA[I have the same questions as John.

I understand the value of the first example to wait X seconds until doing something else, but I don&#039;t get why you would wait until a specific time to execute.

Why not use SQL Agent with a scheduled job?

I assume that second feature simply exists, but that best practices would be to use an agent job?

Is the benefit perhaps for a one time or semi-random AdHoc style situation?

Also how does it handle waiting for a specific time to execute?

Does it check in the background and thus consume resources the entire time it is waiting for the specified date/time or does it have a more efficient way of &quot;sleeping&quot; until it is needed?]]></description>
		<content:encoded><![CDATA[<p>I have the same questions as John.</p>
<p>I understand the value of the first example to wait X seconds until doing something else, but I don&#8217;t get why you would wait until a specific time to execute.</p>
<p>Why not use SQL Agent with a scheduled job?</p>
<p>I assume that second feature simply exists, but that best practices would be to use an agent job?</p>
<p>Is the benefit perhaps for a one time or semi-random AdHoc style situation?</p>
<p>Also how does it handle waiting for a specific time to execute?</p>
<p>Does it check in the background and thus consume resources the entire time it is waiting for the specified date/time or does it have a more efficient way of &#8220;sleeping&#8221; until it is needed?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.sqlauthority.com/2009/01/03/sql-server-time-delay-while-running-t-sql-query-waitfor-introduction/#comment-45311</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Sat, 03 Jan 2009 11:49:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1947#comment-45311</guid>
		<description><![CDATA[Have you ever used WAITFOR in a production environment?

I&#039;ve never really seen much of a use for it and I&#039;d be interested to hear ideas of practical uses for it.

For any situations where I want to delay the start of a query (e.g. DBCC commands run outside of core business hours), I&#039;ve always used SQL Server Agent instead.]]></description>
		<content:encoded><![CDATA[<p>Have you ever used WAITFOR in a production environment?</p>
<p>I&#8217;ve never really seen much of a use for it and I&#8217;d be interested to hear ideas of practical uses for it.</p>
<p>For any situations where I want to delay the start of a query (e.g. DBCC commands run outside of core business hours), I&#8217;ve always used SQL Server Agent instead.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

