Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
create Function getnetsal(@Empno int)returns money
as
begin
declare @sal money,@professionFund money,@professionaltax money,@netsal money
set @professionFund = @sal*0.12;
set @professionaltax =@sal*0.03;
set @netsal=@sal-(@professionFund+@professionaltax)
return @netsal
end;
  
select getnetsal(1)



whenever excute the function that function gives the error"getnetsal' is not a recognized built-in function name ".

already i used
C#
select dbo.getnetsal(1)


but it is not worked also


please help me.
thank u

What I have tried:

select getnetsal(1)


whenever excute the function that function gives the error"getnetsal' is not a recognized built-in function name "
Posted
Updated 21-Jun-16 22:36pm
Comments
Karthik_Mahalingam 22-Jun-16 4:35am    
ensure that getnetsal is created under Correct database (not in master )

1 solution

Strange - when I try with one of mine:
SQL
SELECT dbo.GetFirstWord('hello there')
It works fine.
Except...that function doesn't look right: you don;t give a value to @sal at all, and you aren't using the parameter, so the result would always be NULL.
If I copy your code, and create teh function, then
SQL
select dbo.getnetsal(1)
works, and returns NULL for me OK.
I'd check (in SSMS under "Programmability...Functions...Scalar-valued functions") that the function is in the right DB and that you are executing the SELECT query against that DB.
 
Share this answer
 
Comments
Krishna Veni 22-Jun-16 7:50am    
i don't want null. for suppose you can u pass empid then return the netsalary in table while excuting the function.pls help me
OriginalGriff 22-Jun-16 8:18am    
You aren't using empid, you don't set any value to the variable you base everything else on - so it's null, and null propagates through all expressions. As a result, null is what you get!
If you don't want null, then you have to use something to set the value - but since I have no idea what your DB looks like, or what the function is meant to do, I can't do that for you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900