Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 非确定性函数的替代SqlDependency?_Sql Server 2008_Sqldependency_Non Deterministic - Fatal编程技术网

Sql server 2008 非确定性函数的替代SqlDependency?

Sql server 2008 非确定性函数的替代SqlDependency?,sql-server-2008,sqldependency,non-deterministic,Sql Server 2008,Sqldependency,Non Deterministic,我需要在SqlDependency上使用getdate函数,但这是它的一部分。非确定性函数 我有什么选择呢?如果函数总是返回相同的值,那么函数将是确定性的——只要您对相同的数据使用相同的参数调用它。很明显,像GETDATE或NEWID这样的函数不能满足这个需求 据我所知,唯一的可能性是将非确定性值作为参数传入。看看这个: --This will return the current date, but is non-determinisitic CREATE FUNCTION dbo.TestF

我需要在SqlDependency上使用getdate函数,但这是它的一部分。非确定性函数

我有什么选择呢?

如果函数总是返回相同的值,那么函数将是确定性的——只要您对相同的数据使用相同的参数调用它。很明显,像GETDATE或NEWID这样的函数不能满足这个需求

据我所知,唯一的可能性是将非确定性值作为参数传入。看看这个:

--This will return the current date, but is non-determinisitic
CREATE FUNCTION dbo.TestFunc()
RETURNS DATETIME
WITH SCHEMABINDING
BEGIN
    RETURN GETDATE();
END
GO
--returns 0
SELECT OBJECTPROPERTY(OBJECT_ID('[dbo].TestFunc'), 'IsDeterministic');
GO

--This is deterministic, as it returns nothing else, than the parameter
CREATE FUNCTION dbo.TestFunc2(@CurrentDate DATETIME)
RETURNS DATETIME
WITH SCHEMABINDING
AS
BEGIN
    RETURN @CurrentDate;
END
GO
--returns 1
SELECT OBJECTPROPERTY(OBJECT_ID('[dbo].TestFunc2'), 'IsDeterministic');
GO

--Both return the current date and time
SELECT dbo.TestFunc() AS NonDeterministic
      ,dbo.TestFunc2(GETDATE()) AS Deterministic; 
GO

--Cleaning
DROP FUNCTION dbo.TestFunc;
DROP FUNCTION dbo.TestFunc2;

顺便说一句:你的链接指向德语描述…真的吗?打开链接时,我看到的是英文。可能是翻译过来的。。。我住在一个讲德语的国家,我很确定我能看到德语谢谢!虽然我意识到SqlDependency查询通知的奇怪行为不允许监视器特定列,但这回答了我的问题!