我遇到了问题,并且我没有任何运气研究了Stackoverflow的答案。我已经设法构建一个使用名为GetSubtree_relvalue的函数的存储过程。当函数的参数被硬编码时,存储过程及其函数工作得很好。但是现在我希望函数在执行时使用Stored过程发送的参数固有。将参数从存储过程传递给函数(在存储过程中)
当我用@Client将@attribute_id和USA替换为XX和USA时,它不会返回任何内容。我已调试到目前为止,以便我可以断定该函数运行时不会获得任何值。即使这些参数在存储过程中的值与我硬编码的值完全相同,也是如此。 (我检查过程中的常规选择@客户端,它返回美国。)
我是否错误地参数化功能?我是否需要启动函数参数才能发送/传递给函数?如何让函数进入参数?
我会很高兴所有关于从SP到函数传递参数的输入。
使用SQL Server 2008
感谢
/丹尼尔
函数值硬编码
Insert into att_value_lookup (t.attribute_ID, t.att_value)
Select
t.attribute_ID, t.att_value
From
(Select attribute_id, att_value from relvalue
where attribute_id in (
Select attribute_id from (
select attribute_id
from dbo.GetSubtree_relvalue('XX','USA'))
) as t
函数值参数
Insert into att_value_lookup (t.attribute_ID, t.att_value)
Select
t.attribute_ID, t.att_value
From
(Select attribute_id, att_value from relvalue
where attribute_id in (
Select attribute_id from (
select attribute_id
from dbo.GetSubtree_relvalue('@attribute_id','@client'))
) as t
哇,你打我:) +1 – MatBailie