i need to create a trigger that will update the status field in my table to 'A' (active) when its setToActive date is equal to the current date. The default value of the status field is 'I' (inactive).
i have attached my code below but please see if this would work and do the trick.
CREATE TRIGGER dbo.TRG_MakeActive ON [dbo].[tbQuestion]
FOR UPDATE
AS
BEGIN
DECLARE @idQuestion int
SELECT @idQuestion = IdQuestion
FROM tbQuestion
WHERE convert(char(10),startDate, 101) = convert(char(10),getdate(), 101))
if (@idQuestion != null)
(
UPDATE tbQuestion
SET Active = 1
WHERE idQuestion= @idQuestion
)
END
Thanks in advance guys!
i have attached my code below but please see if this would work and do the trick.
CREATE TRIGGER dbo.TRG_MakeActive ON [dbo].[tbQuestion]
FOR UPDATE
AS
BEGIN
DECLARE @idQuestion int
SELECT @idQuestion = IdQuestion
FROM tbQuestion
WHERE convert(char(10),startDate, 101) = convert(char(10),getdate(), 101))
if (@idQuestion != null)
(
UPDATE tbQuestion
SET Active = 1
WHERE idQuestion= @idQuestion
)
END
Thanks in advance guys!