What is the use of WAITFOR in SQL SERVER ?

 Posted by Lakhangarg on 10/28/2009 | Category: Sql Server Interview questions | Views: 4740
Answer:

Suppose we want to execute one query now one one after some time then we need to use WAITFOR TIME for this.

Sample Query:

BEGIN

SELECT 'Lakhan Pal'
DECLARE @time char(5)
SET @time=CONVERT(char(5),DateAdd(mi, 1, GetDate()),108)
WAITFOR TIME @time
SELECT ' Garg'
END


In the above Code SELECT 'Lakhan Pal' will be execute first and then after 1 min second select statement SELECT ' Garg' will be executed.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response