Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8625009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:40:32+00:00 2026-06-12T07:40:32+00:00

I am using a capturing software, Abbyy FlexiCapture, after user done the verification (some

  • 0

I am using a capturing software, Abbyy FlexiCapture, after user done the verification (some sort of user key in data). It will export captured data into SQL Server 2008 R2

Once SQL Server identify there is an inserted data (new row), it will trigger code to update table Abbyy base on business rule.

The table has two columns called ProcessingDate and DateOfService

My business rule requirement is

  1. If Processing Date is later than Date Of Service 7 month, it will update Table Abbyy
    • column CouponStatus with “Reject“,
    • column RejectCode with “A5“.
  2. If Processing Date is earlier than Date Of ServiceDate 7 month, it will update Table Abbyy
    • column CouponStatus with “Approve”,
    • column RejectCode with “null”.

I am facing an error because some inserted data with Processing Date more than Service Date 7 month, column CouponStatus become “Approve“.

I am not sure is my trigger code problem or date format problem.
when user do validation, the date format is dd/mm/yy,

In SQL Server 2008 R2, my ProcessingDate and DateOfService column’s datatype is date with format yyyy-mm-dd

Here are my trigger code, pls focus start on line 86

USE [master]
GO
/****** Object:  Trigger [dbo].[BusinessRule]    Script Date: 10/03/2012 11:28:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================

ALTER TRIGGER [dbo].[BusinessRule]
ON [dbo].[Abbyy]
AFTER INSERT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;


DECLARE @Identity varchar(225);
DECLARE @RegNo varchar(225);
DECLARE @ProDate date;
DECLARE @SerDate date;
DECLARE @PriKey varchar(255);

SELECT @Identity=EngineNo, @RegNo=VehRegNo, @ProDate=ProcessingDate, @SerDate=DateOfService,@PriKey=DocID FROM Inserted

--If EngineNo not exist in db, update Reject & A1
IF EXISTS (Select EngineNo
            From Abbyy
            Where
                NOT EXISTS
                (Select EngineNo
                 From eDaftarOwnerDetail
                 where eDaftarOwnerDetail.EngineNo = @Identity))

    UPDATE Abbyy
    SET CouponStatus = 'Reject', RejectCode = 'A1'
    WHERE EngineNo = @Identity
    and DocID=@PriKey

--If Vehicle Registration No not exist in db, update Reject & A2
Else If EXISTS (Select VehRegNo
                From Abbyy
                Where
                    NOT EXISTS
                    (Select VehRegNo
                     From eDaftarOwnerDetail
                     Where eDaftarOwnerDetail.VehRegNo = @RegNo))
    UPDATE Abbyy
    SET CouponStatus = 'Reject', RejectCode = 'A2'
    WHERE VehRegNo = @RegNo
    and DocID=@PriKey

--If EngineNo & Vehicle Registration No does not matched, update Reject & A3
Else If EXISTS (Select EngineNo, VehRegNo
                From Abbyy
                Where
                    NOT EXISTS
                    (Select EngineNo, VehRegNo
                     From eDaftarOwnerDetail
                     Where eDaftarOwnerDetail.EngineNo = @Identity
                     and eDaftarOwnerDetail.VehRegNo = @RegNo))
    UPDATE Abbyy
    SET CouponStatus = 'Reject', RejectCode = 'A3'
    WHERE EngineNo = @Identity
    and VehRegNo = @RegNo
    and DocID=@PriKey

-- If EngineNo exist in db more then twice, update Reject & A4
Else If EXISTS (Select COUNT(1)
                From Abbyy
                Where EngineNo = @Identity
                Group by EngineNo 
                Having COUNT(1)>2)
    UPDATE Abbyy
    SET CouponStatus = 'Reject', RejectCode = 'A4'
    WHERE EngineNo = @Identity
    and DocID=@PriKey

-- If ProcessingDate more than ServiceDate 210 days, update Reject & A5 
Else If EXISTS (Select ProcessingDate, DateOfService
                From Abbyy
                Where
                datediff(day, @SerDate, @ProDate)>210)
    UPDATE Abbyy
    SET CouponStatus = 'Reject', RejectCode = 'A5'
    WHERE ProcessingDate = @ProDate
    and DateOfService = @SerDate
    and DocID=@PriKey

Else
UPDATE Abbyy
Set CouponStatus = 'Approve', RejectCode = ''
WHERE EngineNo = @Identity

-- Insert statements for trigger here

END

Appreciate anyone can give me some guideline to solve this problem. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:40:33+00:00Added an answer on June 12, 2026 at 7:40 am

    Do some kind of date formatting before comparison to convert both values to the same format

    Example :

    WHERE CONVERT(VARCHAR,ProcessingDate,102) = CONVERT(VARCHAR,@ProDate,102)
    

    OR

    WHERE CONVERT(DATE,ProcessingDate,102) = CONVERT(DATE,@ProDate,102)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make little high-performance recording application. For capturing, I will be using
I'm capturing webcam data using OpenCV and display them as the Texture for a
Usually, flash streaming is done by capturing webcam video/audio and streaming using NetConnection and
I'm using GLFW for creating OpenGL context and capturing user's input and I wanted
We are capturing a visible tab in a Chrome browser (by using the extensions
I'm having trouble capturing the digits in a string of this format (t|b|bug_|task_|)1234 using
I am pretty new to image capturing using java. Just started working in java.
I am pretty new to image capturing using java. Which is better and easy
I'm capturing images using this code #pragma mark - image capture // Create and
I am capturing image by using camera in my app. 1) it saves image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.