I have a table that maintains the warranty status of products. The default state for 'statusA' for each product warranty is 'active' and 'statusB' is 'expired'
The life span is calculated by using 'dateAdd' function to add the warranty length.
ALL THIS WORKS FINE.
What I want is for the "wStatus" field to change to "expired" whenever the "expired_date" field or status occurs.
That is, I want to automate the 'wstatus' field state based on the weather the warranty is expired or active.
I believe this is a job for a trigger, but I don't know how to do it.
Here is my table
CREATE TABLE [dbo].[warranty] (
[warrantyId] [int] IDENTITY (1, 1) NOT NULL ,
[statusA] [varchar] (15) NOT NULL ,
[statusB] [varchar] (15) NOT NULL ,
[effective_date] [datetime] NOT NULL ,
[expire_date] [datetime] NOT NULL ,
[wStatus] [varchar] (15) NOT NULL, DEFAULT 'Active'
) ON [PRIMARY]
GO
Thanks,
assigned








Bookmarks