tsql - SQL Trigger Update After Insert -


i trying create trigger add calculated field 1 field after insertion. i've been playing around days , use set of eyes. basically, if field policynum empty , couple other parameters met, trigger fire, inserted function couple of housekeeping items.

alter trigger policynumber on consolidated   after insert begin if exists (select i.policynum, i.plancode     inserted     join consolidated c     on c.id = i.id , c.seqn = i.seqn     c.policynum = '' ,     c.plancode '%nyl%'     )  declare @policynumber nvarchar(255) declare @imisid nvarchar(10) declare @seqid int  exec    @policynumber = [dbo].[fn_getnylpolicynumber]  --updating record update consolidated set policynum = @policynumber,  updatedby = 'trigger',  updateddate = getdate() (id = @imisid) , (seqn = @seqid) end 

alter trigger policynumber on consolidated   after insert begin if exists (select i.policynum, i.plancode     inserted     join consolidated c     on c.id = i.id , c.seqn = i.seqn     c.policynum = '' ,     c.plancode '%nyl%'     ) begin declare @policynumber nvarchar(255) declare @imisid nvarchar(10) declare @seqid int  exec    @policynumber = [dbo].[fn_getnylpolicynumber]  --updating record update consolidated set policynum = @policynumber,  updatedby = 'trigger',  updateddate = getdate() (id = @imisid) , (seqn = @seqid) end end 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -