I have a Table structure as
Empid Int,
EmpName Nvarchar,
Salary Numeric(18,2),
DeptNumber
I have Function which take 2 Argument. as :
ALTER Function [dbo].[GetTotalPrice]
(
@Salary int,
@DeptNumber int
)
RETURNS int
AS
BEGIN
Declare @TotalSalary int
Select @TotalSalary=@Salary+@DeptNumber
return @TotalSalary
End
And my Query is how should i develop a Stored procedure Which takes
Each salary and DeptNumber in a Stored Procedure and send that to function and calculate a new Salary. i have tried developing several SP, but could not get any possible solution.
ALTER Proc [dbo].[S7]
AS
BEGIN
Declare @salary int
Declare @DeptNo int
Select EmpId,EmpName, @salary=salary,@DeptNo=DeptNumber,Salary=dbo.GetTotalPrice(@salary,@DeptNo)
from dbo.EmpInf
end
When i tried executing the above code it give the following error:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
You are using the same
SELECTto put data in the variables and returning a result set from the Stored Procedure, you can’t do both in the same statement.