السلام عليكم ورحمته الله وبركاته
ماذا عن الخطا فى هذه function حيث اقوم بجلب رقم الموظف والدرجة الماليه له والمرتب واقوم بحساب الضريبه بنائ على الدرجة
CREATE FUNCTION salarycalc (@degree int,@salary float)
(
@date datetime ,
@tax float
)
RETURNS TABLE
AS
RETURN
(
if exists (select id,sal1,sal2,sal4,sal5,sal6,sal7,sal8,sal9,sal10,sal11,sal12,sal13,sal14,sal15,sal16,sal17,sal18,sal19 from salary where date=@date)
begin
SELECT dbo.emp_degree.emp_id, dbo.emp_degree.sal_name, dbo.degree.name, dbo.salary.sal3
FROM dbo.degree INNER JOIN
dbo.emp_degree ON dbo.degree.id = dbo.emp_degree.sal_name
INNER JOIN dbo.salary ON dbo.emp_degree.emp_id = dbo.salary.id
if dbo.emp_degree.sal_name = 'الدرجة الاولى' then
set @tax =(@salary * 10) \ 100
else if dbo.emp_degree.sal_name = 'الدرجة الثانية' then
set @tax =(@salary * 7) \ 100
end if
endهذا هو الخطا
Msg 102, Level 15, State 1, Procedure salarycalc, Line 7
Incorrect syntax near '('.
Msg 137, Level 15, State 2, Procedure salarycalc, Line 18
Must declare the scalar variable "@date".
Msg 156, Level 15, State 1, Procedure salarycalc, Line 24
Incorrect syntax near the keyword 'then'.
Msg 102, Level 15, State 1, Procedure salarycalc, Line 25
Incorrect syntax near '\100'.
Msg 156, Level 15, State 1, Procedure salarycalc, Line 26
Incorrect syntax near the keyword 'then'.
Msg 102, Level 15, State 1, Procedure salarycalc, Line 27
Incorrect syntax near '\100'.
وشكرا
