Stored Procedure To set a variable value to a Individual column
19,295
You are using the same SELECT
to put data in the variables and returning a result set from the Stored Procedure, you can't do both in the same statement.
ALTER Proc [dbo].[S7]
AS
BEGIN
Select EmpId,EmpName, Salary=dbo.GetTotalPrice(salary,DeptNumber) from dbo.EmpInf
end
Author by
Abhishek gupta
I have a 2 Year experience working with .net Technologies. I like Coding and have knowledge of C#,Asp.net,Wcf,Webservice,MVC architecture, HTML,Javascript,Jquery and Sql Server 2008.
Updated on June 16, 2022Comments
-
Abhishek gupta almost 2 years
I have a
Table structure
asEmpid 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
andDeptNumber
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.