过程或函数“”需要参数'',这是未提供的 [英] Procedure or function “” expects parameter '', which was not supplied
问题描述
嗨朋友们:
我是SQL新手并尝试写存储过程。我很难将默认值作为输出结果。
Hi Friends:
I am new to SQL and trying write stored proc. I am having some difficulties to get default values as an output result.
I have 2 table:
1)Student_Input:
InputID SectionID ParameterName Sequence
1 100 FirstName 1
2 100 MiddleName 2
3 100 LastName 3
2)Student_Input_details:
ParameterName ParameterValue DefaultValue
FirstName John 1
FirstName Troy 0
FirstName Mark 0
我试图从Student_Input调用ParameterName,并将其默认值从Student_Input_Details调用为一个表中的输出。我正在尝试以下查询,但我收到以下错误:
I am trying to call ParameterName from Student_Input and Its default value from Student_Input_Details as an output in one table. I am trying with following query but I am getting following error:
Msg 201, Level 16, State 4, Procedure Getparameterdefaultvalues, Line 0
Procedure or function 'Getparameterdefaultvalues' expects parameter '@ParameterValue', which was not supplied.
我相信我在这里缺少一些重要的东西。
I am sure I am missing something important here.
Create Procedure Getparameterdefaultvalues
(
@ParameterName varchar(50) ,
@ParameterValue varchar(50) out
)
As
Begin
Select @ParameterValue = DefaultValue from Student_Input_details where ParameterName=@ParameterName
End
Execute Getparameterdefaultvalues 1
我需要结果(即ParameterName应该只显示它的默认值为r untime):
I need result like (i.e. ParameterName should only display its default value at runtime):
ParameterName ParameterValue
FirstName John
道歉如果我的问题没有那么清楚。任何帮助都会得到! Thx:)
Apologies If my question is not so cleared. Any help would be grate!! Thx :)
推荐答案
虽然我不确定,这是一个好的概念,错误信息是由错误的语法引起的。
只使用一个参数调用存储过程。但是你认为你的输出参数会放在哪里?在虚空中?不可以。您必须提供一个变量来填充输出参数。点击这里: http://msdn.microsoft.com/en-us /library/ms187004(v=sql.105).aspx [ ^ ]
Although I am not sure, that this is a good concept, the error message is caused by wrong syntax.
You call the stored procedure with only a single parameter. But where do you think your output parameter will be put? In the void? No. You have to give a variable to be filled with the output parameter. Check out here: http://msdn.microsoft.com/en-us/library/ms187004(v=sql.105).aspx[^]
这篇关于过程或函数“”需要参数'',这是未提供的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!