Hi Ann
If you have access to the application code then a check can be added before record is inserted in the application itself. or
the other solution which we did to overcome duplicate timesheet is to create a trigger on the database table. We haven't implemeted this solution yet to be tested on UAT.
/****** Object: Trigger [dbo].[trg_DuplicateTS] Script Date: 07/18/2013 15:23:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create TRIGGER [dbo].[trg_StopDuplicateTS] ON [dbo].[PDK10000] FOR insert
AS
DECLARE @A INT
SET @A=(
SELECT TOP 1 substring(T1.PDK_TS_NO,LEN(T1.PDK_TS_NO),1)
FROM inserted AS T1
JOIN [PDK10000] AS T2
ON substring(T1.PDK_TS_NO,1,LEN(T1.PDK_TS_NO)-1)=substring(T2.PDK_TS_NO,1,LEN(T2.PDK_TS_NO)-1)
ORDER BY substring(T1.PDK_TS_NO,LEN(T1.PDK_TS_NO),1) DESC)
print @A
IF(@A>1)
BEGIN
ROLLBACK TRAN
RAISERROR('Timesheet Already Exists Duplicates Are Not Allowed',16,1)
END