T-SQL 中的睡眠命令?

Sleep Command in T-SQL?(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 中的睡眠命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)