我创建了一个存储过程,通过提供员工收入来查找姓名和名称
Create PROCEDURE GetEmployeessalaryInOutputVariable
(
@Income INT, -- Input parameter, Income of the Employee
@FirstName VARCHAR (30) OUT, -- Output parameter to collect the Employee name
@Title VARCHAR (30)OUT -- Output Parameter to collect the Employee designation
)
AS
BEGIN
SELECT FirstName=@FirstName, Title=@Title
FROM Salaries WHERE @Income=Income
END
在此之后我尝试按如下方式执行Sp
Declare @FirstName as varchar(30) -- Declaring the variable to collect the Employeename
Declare @Title as varchar(30) -- Declaring the variable to collect the Designation
Execute GetEmployeessalaryInOutputVariable 500 , @FirstName output, @Title output
select @FirstName,@Title as Designation
一旦我写上述语句,就会显示错误显示
Invalid object name GetEmployeessalaryInOutputVariable
为什么它表现得像那样,虽然程序已经创建并存在?
另外,如何运行查询以获得正确的结果?
答案 0 :(得分:1)
Execute GetEmployeessalaryInOutputVariable 500 , 'FirstName', 'Title'
OR
Declare @FirstName as varchar(30)
set @FirstName = 'FirstName'
Declare @Title as varchar(30)
set @Title = 'title'
Execute GetEmployeessalaryInOutputVariable 500 , @FirstName, @Title
答案 1 :(得分:0)
Create PROCEDURE GetEmployeessalaryInOutputVariable
(
@Income INT, -- Input parameter, Income of the Employee
@FirstName VARCHAR (30) OUT, -- Output parameter to collect the Employee name
@Title VARCHAR (30)OUT -- Output Parameter to collect the Employee designation
)
AS
BEGIN
SELECT @FirstName = FirstName, @Title=Title
FROM Salaries WHERE @Income=Income
END
你的SP应该是这样的