How to convert the following SQL-C# logic to syntactically-correct SQL code (SQL Server 2005)?
"Description", "LeaveType", "MonthlyMaxLeave", "YearlyMaxLeave" are the column names in the table EmpTab.
I have written a basic logic to calculate the PayLeave and NonPayLeave, and to display its final values. Assume that the fields "Description" and "LeaveType" always contains the values "Sick" and "Yearly" respectively. Please do not worry about the data in the table. The field values in the table may be customized as per the requirements.
Just correct the syntax in the code so as to meet the SQL standards, as well as to display the PayLeave and NonPayLeave values based on the calculation logic shown below.
CREATE FUNCTION [dbo].[Leave]
DECLARE @PayLeave INT,
SET @PayLeave = 0;
SET @NonPayLeave = 0;
IF((ImDescription == "Sick") AND (ImLeaveType == "Yearly"))
IF((ImMonthlyMaxLeave > 1) OR (ImYearlyMaxLeave > 10 ))
@NonPayLeave = @NonPayLeave + 1;
@PayLeave = @PayLeave + 1;
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)