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 中的睡眠命令?


- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01