睡眠命令在T-SQL? [英] Sleep Command in T-SQL?

查看:306
本文介绍了睡眠命令在T-SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法写一个T-SQL命令,只是使它睡了一段时间?我写异步Web服务,我想能够运行一些测试,看看是否异步模式是真的要使它更具可扩展性。以模拟,即缓慢的外部服务,我想能够调用与运行缓慢的脚本一个SQL服务器,但实际上并没有处理一吨的东西。

Is there to way write a T-SQL command to just make it sleep for a period of time? I am writing a web service asynchronously and I want to be able to run some tests to see if the asynchronous pattern is really going to make it more scalable. In order to "mock" an external service that is slow, I want to be able to call a SQL server with a script that runs slowly, but isn't actually processing a ton of stuff.

推荐答案

WAITFOR 命令

例如。

-- wait for 1 minute
WAITFOR DELAY '00:01'

-- wait for 1 second
WAITFOR DELAY '00:00:01'

这个命令可以让你的高度precision的,而是<一个href=\"http://blogs.msdn.com/psssql/archive/2009/05/29/how-it-works-sql-server-timings-and-timer-output-gettickcount-timegettime-queryperformancecounter-rdtsc.aspx\">only在10ms内准确 - 一个典型的机器上16ms的因为它依赖于的GetTickCount 。因此,例如,呼叫 WAITFOR DELAY '00:00:00:001 很可能导致没有等待。

This command allows you a high degree of precision but is only accurate within 10ms - 16ms on a typical machine as it relies on GetTickCount. So, for example, the call WAITFOR DELAY '00:00:00:001' is likely to result in no wait at all.

这篇关于睡眠命令在T-SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆