Simulate Timeout - WAITFOR - C# Thread.Sleep() Equivalent
Here we look at WAITFOR.
If your using C#, you may know of Thead.Sleep(), which will make the process (or thread) effectively pause what it is doing, wait the specified time span, and once this has passed, the process will continue onto the next line of code. Well WAITFOR is the SQL equivalent of Thread.Sleep.
So in SQL Server, we have WAITFOR. Let's see an example
In this example, we use WAITFOR to wait for 45 seconds before continuing execution onto the next SQL command. Perfect to simulate the 30 second timeout in a .NET Web Application:
WAITFOR DELAY '00:00:45';