实例:
sql
execute sp_executesql N'select count(1)
FROM table X2 WITH(NOLOCK)
WHERE X2.UPDDTTM > @DT_START AND X2.UPDDTTM <= @DT_END ',
N'@DT_START datetime,@DT_END datetime',
@DT_START='2025-01-02 10:06:58.620',@DT_END='2025-01-02 10:09:35.457'
参考:sp_executesql (Transact-SQL) - SQL Server | Microsoft Learn