SQL

[복사되는블로그 꼬마갱이] MS-SQL 트리거 예제

administrators 2012. 12. 12. 14:50

--MS-SQL 트리거 예제




SET
ANSI_NULLS ON GO SET QUOTED_IDENTIFIER on GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER TRIGGER [dbo].[TRG_tablename_INS_AFTER] ON [dbo].[tablename] AFTER INSERT AS BEGIN -- SET NOCOUNT on added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @iPK01 varchar(8) = (SELECT field_PK01 FROM INSERTED); DECLARE @iPK02 numeric(5) = (SELECT field_PK02 FROM INSERTED); update tablename set filed01 = 'Y' , filed02 = '0000' , filed03 = CONVERT(varchar, getdate(), 112) , filed04 = CUST_NM where field_PK01 = @iPK01 AND field_PK02 = @iPK02 END GO





- write by 꼬마갱이 2012.12.12 -







.