fix logic to save contentauditid in gridaudits identified when trying to delete a procedure containing grids

This commit is contained in:
Rich 2011-09-08 20:39:30 +00:00
parent 8b2f1b34f5
commit 39a0685edb

View File

@ -1817,6 +1817,8 @@ ALTER trigger [dbo].[tr_Contents_Delete] on [dbo].[Contents] instead of delete a
select ii.ContentID,ii.Number,ii.Text,ii.Type,ii.FormatID,ii.Config,ii.DTS,ii.UserID,ii.DeleteStatus,ii.ActionDTS
from tblContents ii inner join deleted dd on dd.ContentID = ii.ContentID
where ii.DeleteStatus > 0
update ga set ga.contentauditid = (select max(auditid) from contentaudits where contentid = ga.contentid and deletestatus = ga.deletestatus)
from gridaudits ga join deleted dd on ga.contentid = dd.contentid where ga.contentauditid = 0
end
go
@ -2392,7 +2394,7 @@ on [dbo].[GridAudits]
after INSERT
AS
begin
update ga set ga.contentauditid = (select max(auditid) from contentaudits where contentid = ii.contentid)
update ga set ga.contentauditid = (select isnull(max(auditid),0) from contentaudits where contentid = ii.contentid)
from inserted ii
inner join gridaudits ga on ii.auditid = ga.auditid
end