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

编程入门 行业动态 更新时间:2024-10-23 08:32:26
本文介绍了SQL Server 中的不精确列是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Creating index on computed column of type nvarchar raises following error:

无法在表MyTable"上创建索引或统计信息MyIndex",因为计算列 'MyColumn' 不精确且未持久化.考虑从索引或统计键或标记中删除列计算列持久化.

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 列必须持久化才能被索引:

任何包含公共语言运行时 (CLR) 表达式的计算列都必须是确定性的并标记为 PERSISTED,然后才能对该列建立索引.计算列定义中允许使用 CLR 用户定义类型表达式.只要类型是可比较的,就可以对类型为 CLR 用户定义类型的计算列进行索引.有关详细信息,请参阅 CLR 用户定义类型.

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.

坚持这个专栏,我怀疑它会起作用.

Persist the column and I suspect it will work.

更多推荐

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

本文发布于:2023-11-27 04:27:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不精确   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!