如何在MVC中通过审查过程字符串查询实时监控更新数据

本文关键字:查询 字符串 实时 监控 数据 更新 过程 审查 MVC | 更新日期: 2023-09-27 17:53:51

我可以使用什么方法实时监控更新数据?从以下存储过程返回的数据,写入字符串查询:

BEGIN TRAN
USE [MyDataBase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[MySp]
(    
    @UserId INT
)
as
BEGIN
CREATE TABLE #tmp (T1 INT,T2 NVARCHAR(500))
declare @sql nvarchar(max)
SET @sql='select  [T1], [dbo].[MyFunction]('+ cast(@UserId as nvarchar(20))+',[T1],0) as [T2]
          from [dbo].[MyTable]               
          where ( [X] in(50,60) or [Y] in(520,530) ) and  [dbo].[MyFunction]('+ cast(@UserId as nvarchar(20)) +',[T1],0) <>0'
    sp_executesql @sql        
END

EDIT:

过程非字符串查询为:

BEGIN TRAN
USE [MyDataBase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[MySp]
(    
    @UserId INT
)
as
BEGIN
select  [T1], [dbo].[MyFunction]('+ cast(@UserId as nvarchar(20))+',[T1],0) as [T2]
          from [dbo].[MyTable]               
          where ( [X] in(50,60) or [Y] in(520,530) ) and  [dbo].[MyFunction]('+ cast(@UserId as nvarchar(20)) +',[T1],0) <> 0       
END

但是这种方法也不能正确工作。该怎么办?

如何在MVC中通过审查过程字符串查询实时监控更新数据

SQLDependency不支持时态表

请参见SqlDependency的限制