1
CREATE procedure [dbo].[usp_insertleavedetails]
@Emp_id int ,
@Rec_Name varchar(50) ,
@CompanyName varchar(30) ,
@Month_Year varchar(9),
@Task varchar(20) ,
@RemainingDaysofLeave varchar(2),
@NoOfDaysLeavTakn varchar(12) ,
@NoOfAvailblLeav varchar ,
@LossofPay varchar(2) ,
@LeaveTakndates varchar(200),
@TtlLeavTakn varchar(12)
AS
BEGIN
Insert into tbl_Leavetbl(Emp_id,Rec_Name,CompanyName,Month_Year,Task,RemainingDaysofLeave,NoOfDaysLeavTakn ,NoOfAvailblLeav ,LossofPay ,LeaveTakndates,TtlLeavTakn)
Values(@Emp_id ,@Rec_Name,@CompanyName,@Month_Year,@Task,@RemainingDaysofLeave,@NoOfDaysLeavTakn,@NoOfAvailblLeav,@LossofPay,(SELECT LEFT(Leavetakndates,CASE WHEN CHARINDEX(',',Leavetakndates)>0 THEN LEN(Leavetakndates)-1 ELSE LEN(Leavetakndates) END) FROM tbl_Leavetbl),@TtlLeavTakn)
END
這是插入過程我用,在「LeaveTakndates」本場我將與comma.I分隔日期值需要刪除最後一個逗號。雖然插入值,我需要從日期刪除最後一個逗號,並在插入過程保存
提供樣本數據 – Mani