- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用以下代码创建索引 View (这样我就可以将其发布到复制表中):
CREATE VIEW lc.vw_dates
WITH SCHEMABINDING
AS
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), number) AS SettingDate
FROM lc.numbers
WHERE number<8
GO
CREATE UNIQUE CLUSTERED INDEX
idx_LCDates ON lc.vw_dates(SettingDate)
lc.numbers 只是一个包含 1 列 (number
) 的表格,按第 1-100 行递增。
但是,我一直收到错误:
Column 'SettingDate' in view 'lc.vw_dates' cannot be used in an index or statistics or as a partition key because it is non-deterministic.
我意识到 GETDATE()
是不确定的。但是,有没有办法让它发挥作用?
我正在使用 MS SQL 2012。
编辑:希望能够转换 GetDate() 以使其具有确定性(在剥离时间时似乎应该如此)。如果没有人知道执行此操作的方法,我将关闭此问题并将创建日历表的建议标记为正确。
最佳答案
确定性函数的定义(来自 MSDN )是:
Deterministic functions always return the same result any time they are called with a specific set of input values and given the same state of the database. Nondeterministic functions may return different results each time they are called with a specific set of input values even if the database state that they access remains the same.
请注意,此定义不涉及结果必须保持不变的任何特定时间跨度。对于给定的输入,它必须始终是相同的结果。
您可以想象的任何函数总是返回函数被调用时的日期,根据定义,如果您今天运行它并在第二天再次运行它,将返回不同的结果(无论数据库的状态)。
因此,返回当前日期的函数不可能是确定性的。
对这个问题的唯一可能的解释是,如果你愿意将一些关于今天是哪一天的信息作为输入传递给函数,那么唯一可能的解释就是确定性函数。
类似于:
select fn_myDeterministicGetDate('2015-11-25')
但我认为,就您而言,这会打败重点。
关于tsql - 获取今天日期的确定性函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33883877/
我使用 Deflater 编写了一个备份程序SHA-1 用于存储文件和哈希值。我看到Java的Deflater使用zlib 。如果我显式设置 Deflater 的级别,无论平台和 JRE 版本如何,我
考虑以下算法: r = 2 while r >= 1: x = -1 + 2 * random.random() y = -1 + 2 * random.random() r
我正在编写一个持久保存到磁盘的映射类。我目前只允许 str键,但如果我可以使用更多类型会很好:希望最多可以是任何可散列的(即与内置 dict 相同的要求),但更合理的是我会接受字符串、unicode、
我有一个不使用随机化的脚本,当我运行它时会给出不同的答案。我希望每次运行脚本时答案都是一样的。该问题似乎只发生在某些(病态)输入数据上。 该代码段来自一种计算线性系统特定类型 Controller 的
这对我来说不是问题,没有它我也可以生活,但我只是好奇这是否可能以及如何实现。 今天我了解到,scrapy.Request 不会按照启动的顺序完成。 伪代码示例: class SomeSpider(sc
我正在运行这个 SVD来自 scipy 的求解器,代码如下: import numpy as np from scipy.sparse.linalg import svds features = np
我正在尝试使用确定性 Miller-Rabin 算法实现素数检查功能,但结果并不总是正确的:在检查前 1,000,000 个数字时,它只找到 78,495 而不是 78,498。 这是使用 [2, 7
我正在审查各种 Android 声音 API,我想知道我应该使用哪一个。我的目标是获得低延迟的音频,或者至少是关于播放延迟的确定性行为。 我们遇到了很多问题,Android 声音 API 似乎很垃圾,
过去,我处理过对时间要求严格的软件开发。这些应用程序的开发基本上是这样进行的:“让我们编写代码,测试延迟和抖动,并优化它们,直到它们在可接受的范围内。”我觉得这非常令人沮丧。这不是我所说的 适当的工程
给定: SQL Server 表名为 TEST_TABLE TEST_TABLE 中名为 TEST_FIELD 的列 VARCHAR(50) NOT NULL 第 1 行:10YR3/6 第 2 行:
我在 64 位 Windows PC 上使用 Microsoft Visual Studio Community 2015,版本 14.xxx。 程序读取一个文本文件,其中每一行都是桥牌(四名玩家,每
我需要在 PHP 中创建一个可证明公平(确定性和种子)加密安全 (CS) 随机数生成器。我们正在运行 PHP 5,而 PHP 7 现在并不是一个真正的选择。但是,我找到了 PHP 7 的新 CS 函数
我是一名优秀的程序员,十分优秀!