USE [LAB_DB]
GO

/****** Object:  Trigger [dbo].[ChangePriorityToSTAT]    Script Date: 1/4/2569 14:26:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Sukit>
-- Create date: <2023-08-07>
-- Description:	<update IREQ_PRIORITY to S if IREQ_WARD_CODE is ER>
-- =============================================
CREATE TRIGGER [dbo].[ChangePriorityToSTAT] 
   ON  [dbo].[tbl_lab_information_Request] 
   AFTER INSERT,UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
	DECLARE @LN NVARCHAR(20);
	select @LN = [IREQ_LN] FROM INSERTED;

	UPDATE [dbo].[tbl_lab_information_Request]
	SET [IREQ_PRIORITY] = 'S'
	WHERE [IREQ_LN] = @LN and [IREQ_WARD_CODE] = 'ER'
END

GO


Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: