选择函数值在索引上显示 nvarchar(4000)
我有一个正在尝试为其设置索引的视图。视图的选择列之一执行返回值为 varchar(250) 的用户定义函数。但是,当我尝试在该列上设置索引时,我看到大小为 nvarchar(4000)。这是为什么?如果我继续设置索引,会导致问题吗?
I have a view that I'm trying to setup an Index for. One of the select columns for the view executes a user-defined function that has a return value of varchar(250). However, when I try to setup an Index on that column, I see a size of nvarchar(4000). Why is that and will that cause a problem if I continue to setup my index?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运行
sp_refreshview 'YourViewName'
是否可以解决该问题? (我认为您还需要更改视图以使用WITH SCHEMABINDING
)Does running
sp_refreshview 'YourViewName'
resolve the issue? (I think you will need to change the view to useWITH SCHEMABINDING
as well)我认为你在这里的主要建议是放弃标量 udf。它们会严重拖累性能。 udf 是否有合法的商业理由?
将代码从标量函数中取出并将其直接放置在视图内,看看这是否可以缓解您的问题。
i think your main suggestion here is going to be to ditch the scalar udf. they're an awful performance drag. is there a legitimate business reason for the udf?
pull the code out of the scalar function and place it inside of the view directly and see if that alleviates your problem.