gpt4 book ai didi

sql - SQL Server 中的不精确列是什么?

转载 作者:行者123 更新时间:2023-12-02 12:05:49 24 4
gpt4 key购买 nike

nvarchar 类型的计算列上创建索引会引发以下错误:

Cannot create index or statistics 'MyIndex' on table 'MyTable' because the computed column 'MyColumn' is imprecise and not persisted. Consider removing column from index or statistics key or marking computed column persisted.

不精确列是什么意思?

更新。定义如下:

alter table dbo.MyTable
add [MyColumn] as dbo.MyDeterministicClrFunction(MyOtherColumn)
go
create index MyIndex on dbo.MyTable(MyColumn)
go

更新2。 MyDeterministicClrFunction 定义如下:

[SqlFunction(IsDeterministic = true)]
public static SqlString MyDeterministicClrFunction(SqlString input)
{
return input;
}

最佳答案

Per MSDN, CLR Function columns must be persisted to be indexed:

Any computed column that contains a common language runtime (CLR) expression must be deterministic and marked PERSISTED before the column can be indexed. CLR user-defined type expressions are allowed in computed column definitions. Computed columns whose type is a CLR user-defined type can be indexed as long as the type is comparable. For more information, see CLR User-Defined Types.

坚持该专栏,我怀疑它会起作用。

关于sql - SQL Server 中的不精确列是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10484036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com