我可以使用哪些方法实时监控更新数据? 从以下存储过程返回的数据写为字符串查询:
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
编辑1:
过程非字符串查询是:
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
但这种方法也不能正常工作。该怎么办?