gpt4 book ai didi

sql-server - sqlmetal 无法用全文提取 udf

转载 作者:行者123 更新时间:2023-12-03 11:23:40 25 4
gpt4 key购买 nike

错误信息:

Warning : SQM1014: Unable to extract function 'dbo.ProductFamilyIndex_EN' from SqlServer. Null or empty full-text predicate.

函数定义为:
CREATE FUNCTION [dbo].[ProductFamilyIndex_EN]
(
@topn int,
@keywords nvarchar(4000)
)
RETURNS TABLE
AS
RETURN
(
select top (@topn) ProductFamilyID
from (

select pf.ProductFamilyID, t.[RANK] as _rank
from containstable(ProductFamily, (Name_EN), @keywords, LANGUAGE 'English', @topn) t
inner join ProductFamily pf on(pf.ProductFamilyID=t.[KEY])

union all

select p.ProductID as ProductFamilyID, t.[RANK] as _rank
from containstable(Product, (LongDescription_EN, ShortDescription_EN), @keywords, LANGUAGE 'English', @topn) t
inner join Product p on(p.ProductID=t.[KEY] and p.ProductFamilyID is null and p.Deleted is null)

) t
group by ProductFamilyID
order by max(_rank) desc
)

不要被内部的联合弄糊涂了——这只是意味着没有家庭的产品本身就是一个家庭。

试图为参数提供默认值:
@topn int = 1000,
@keywords nvarchar(4000) = 'test'

结果相同。

使用 .NET 3.5 和 sql2008。

最佳答案

正如您所提到的,SQLMetal 需要一个返回类型。

解决此问题的另一种方法是在存储过程中显式设置默认值:
SET @topn = COALESCE(@topn, 1000)
把那个扔在 SELECT 之前语句以确保任何 NULL 参数都将返回有效值。

这不仅对 SQLMetal 有用,而且对使用此函数的任何人都有用。

关于sql-server - sqlmetal 无法用全文提取 udf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3668005/

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