Create Function GetProducts (@AttributeValue NVARCHAR(max))
RETURNS NVARCHAR
AS
BEGIN
DECLARE @CountA INT
DECLARE @CountB INT
DECLARE @ProductValue NVARCHAR(max)
SELECT @CountA = Count(*)
FROM CRM_fn_ac(@AttributeValue)
SELECT @CountB = Count(*)
FROM product
WHERE filteredviewname = 'filteredciti_ac
AND attributename ='c_products'
AND value IN (SELECT * FROM CRM_fn_ac(@AttributeValue)
IF @CountA =@CountB
BEGIN
SELECT @ProductValue= @AttributeValue
END
RETURN @ProductValue
END
我在IF
条件附近收到错误。我想设置
productvalue = attributevalue when CountA = CountB
答案 0 :(得分:0)
添加缺少的括号...
改变这个:
SELECT @CountB = Count() from product where filteredviewname='filteredciti_ac and attributename ='c_products' and value in (select * from CRM_fn_ac(@AttributeValue)
对此:
SELECT @CountB = Count() from product where filteredviewname='filteredciti_ac' and attributename ='c_products' and value in (select * from CRM_fn_ac(@AttributeValue))
在 filteredviewname 列上过滤时,您也忘了关闭单引号...