I have two tables data as Leave and LeaveTrans
Leave Table Data
ID Name
1 CL
LeaveTrans Table Data
LID ID Category MaxDays BalanceDays
1 1 1 10 15
2 1 2 11 11
3 1 3 2 4
I am trying to update the LeaveTrans Table on two conditions
1)trying to update the category,if category is already existed under ID,I am not going to update the value.Showing Errorpop message.It is working fine with this below stored procedure.
ALTER proc [dbo].[spCheckDuplicateRecordForUpdate]
(@ID int,@Category int,@Value int Out)
AS
BEGIN
IF EXISTS(Select TOP 1 ID from LeaveTrans where ID=@ID AND Category=@Category)
set @Value = 2;
Else
SET @Value=0;
END
2)Already existed LeaveTrans Data,want to update only MaxDays,BalanceDays.
which Could not get any idea to do these two in one stored procedure.
I want to do the two conditions,How can i achieve this any idea?