Sleep Command in T-SQL?(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'
此命令允许您高度精确但仅在 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 中的睡眠命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:T-SQL 中的睡眠命令?
基础教程推荐
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
