如何在sql中创建索引

编程入门 行业动态 更新时间:2024-10-26 04:21:30
本文介绍了如何在sql中创建索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

ALTER 功能 dbo.getThisPVFooterAmount( @ PVoucherHeaderId int , @ FooterAccountId int ) RETURNS money AS BEGIN return (从 trans_PurchaseVoucherDetails ( nolock ) 其中 PurchaseVoucherHeader_Id = @ PVoucherHeaderId 和 Record_Type = ' F' 和帐户_Id = @ FooterAccountId) END

我有这个功能。如何在PurchaseVoucherHeader_Id上创建索引,Record_Type,Account_Id ????

解决方案

仅限对于相同的参数 - 确定性的函数 - 总是返回相同结果的函数可以被索引。

hi

CREATE INDEX index_name ON table_name(column_name)

ALTER FUNCTION dbo.getThisPVFooterAmount ( @PVoucherHeaderId int ,@FooterAccountId int) RETURNS money AS BEGIN return (select Amount from trans_PurchaseVoucherDetails with (nolock) where PurchaseVoucherHeader_Id=@PVoucherHeaderId and Record_Type ='F' And Account_Id =@FooterAccountId ) END

I have this function. how to create index on PurchaseVoucherHeader_Id,Record_Type,Account_Id ????

解决方案

Hi, Only functions that always return the same result for the same parameters—functions that are deterministic—can be indexed.

hi

CREATE INDEX index_name ON table_name (column_name)

更多推荐

如何在sql中创建索引

本文发布于:2023-10-23 18:49:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521712.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   如何在   sql

发布评论

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

>www.elefans.com

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