빈 번호를 찾아가면서 일련번호를 부여하는 트리거
create trigger TRG_MEMBER_INS on member instead of insert as begin set nocount on; begin tran begin try declare @GET_SN int declare @MIN_SN int declare @NEW_SN int declare @MAX_SN int select @GET_SN = sn from inserted if @GET_SN IS NULL OR exists(select * from member where sn = @GET_SN) begin select @MIN_SN = MIN(SN) from member select top 1 @NEW_SN = RN from ( select sn,(row_number() over (orde..
청강컴정/DataBase
2009. 5. 4. 17:26