T
troy
I currenty have 7 fileds from 4 tables (source). I would like the data if it
has changed in one filed or even all seven if they have changed to be updated
into my source table. The problem is the source table has a primary key but
it is not necessary to update that field of course. How would I go about
setting up the query to make this happen. I have tried everything from not
show or moving th primay key to checking all properites etc.All tables are
included in the query set. Here is my SQL if needed. Thank you in advance!
UPDATE dbo_tblSaaDocument RIGHT JOIN (dbo_tblObligationType INNER JOIN
(dbo_TblProductVersion INNER JOIN (DEV_dbo_TblProduct RIGHT JOIN
dbo_TblProduct ON DEV_dbo_TblProduct.ProductId = dbo_TblProduct.ProductId) ON
dbo_TblProductVersion.ProductId = dbo_TblProduct.ProductId) ON
dbo_tblObligationType.ObligationTypeID = dbo_TblProduct.ObligationTypeID) ON
dbo_tblSaaDocument.SaaDocumentID = dbo_tblObligationType.SaaDocumentID SET
DEV_dbo_TblProduct.ProductId = [dbo_tblProduct]![ProductID],
DEV_dbo_TblProduct.StateAbbr = [dbo_TblProduct]![StateAbbr],
DEV_dbo_TblProduct.ProductLine = [dbo_tblObligationType]![ProductLine],
DEV_dbo_TblProduct.BondAmtStd = [dbo_TblProductVersion]![BondAmtStd],
DEV_dbo_TblProduct.BondAmtMax = [dbo_TblProductVersion]![BondAmtMax],
DEV_dbo_TblProduct.BondType = [dbo_tblObligationType]![BondType],
DEV_dbo_TblProduct.BondTermMonths = [dbo_TblProductVersion]![BondTermMonths],
DEV_dbo_TblProduct.CancelDays = [dbo_TblProductVersion]![CancelDays],
DEV_dbo_TblProduct.ObligationTypeID = [dbo_TblProduct]![ObligationTypeID],
DEV_dbo_TblProduct.CategoryId = [dbo_tblObligationType]![CategoryID],
DEV_dbo_TblProduct.BondExpirationDate =
[dbo_TblProductVersion]![BondExpirationDate],
DEV_dbo_TblProduct.AvailableOnline = [dbo_TblProduct]![Available Online],
DEV_dbo_TblProduct.MinCreditScore = [dbo_TblProductVersion]![MinCreditScore],
DEV_dbo_TblProduct.BondEffectiveDate =
[dbo_TblProductVersion]![BondEffectiveDate], DEV_dbo_TblProduct.ClassCode =
[dbo_tblSaaDocument]![ClassCode], DEV_dbo_TblProduct.RiskType =
[dbo_TblProductVersion]![RiskType], DEV_dbo_TblProduct.RateType =
[dbo_TblProductVersion]![RiskType], DEV_dbo_TblProduct.RenewalMethod =
[dbo_TblProductVersion]![RenewalMethod], DEV_dbo_TblProduct.RateCode =
[dbo_TblProductVersion]![RateCode],
DEV_dbo_TblProduct.BondObligationDescription =
[dbo_TblProduct]![BondObligationDescription], DEV_dbo_TblProduct.ObligeeId =
[dbo_TblProduct]![ObligeeID], DEV_dbo_TblProduct.SpecialInstructions =
[dbo_TblProductVersion]![SpecialInstructions], DEV_dbo_TblProduct.Description
= [dbo_tblProductVersion].[Description], DEV_dbo_TblProduct.FormId =
[dbo_tblProductVersion].[NewBusinessFormId], DEV_dbo_TblProduct.BondAmtMin =
[dbo_TblProductVersion]![BondAmtMin], DEV_dbo_TblProduct.Attachments =
[dbo_TblProductVersion].[Attachments], DEV_dbo_TblProduct.Countersignatures =
[dbo_TblProductVersion].[Countersignatures], DEV_dbo_TblProduct.EAndOFlag =
[dbo_TblProductVersion].[EAndOFlag]
WHERE (((DEV_dbo_TblProduct.ProductId)<>[dbo_tblProduct]![ProductID])) OR
(((DEV_dbo_TblProduct.StateAbbr)<>[dbo_tblProduct].[Stateabbr]) AND
((DEV_dbo_TblProduct.Countersignatures)=IIf(Nz([dbo_tblProductversion]![Countersignatures],0)=-1,"Y","N")
And
(DEV_dbo_TblProduct.Countersignatures)<>"[dbo_tblProductVersion].[Countersignatures]"))
OR (((DEV_dbo_TblProduct.ProductLine) Not Like
[dbo_tblObligationType].[ProductLine]) AND
((DEV_dbo_TblProduct.BondExpirationDate)<>[dbo_TblProductVersion].[BondExpirationDate])
AND ((DEV_dbo_TblProduct.AvailableOnline)<>[dbo_TblProduct].[Available
Online]) AND
((DEV_dbo_TblProduct.MinCreditScore)<>[dbo_TblProductVersion].[MinCreditScore])
AND
((DEV_dbo_TblProduct.BondEffectiveDate)<>[dbo_TblProductVersion].[BondEffectiveDate])
AND ((DEV_dbo_TblProduct.ClassCode)<>[dbo_tblSaaDocument].[ClassCode]) AND
((DEV_dbo_TblProduct.RiskType)<>[dbo_TblProductVersion].[RiskType]) AND
((DEV_dbo_TblProduct.RateType)<>[dbo_TblProductVersion]![RateType]) AND
((DEV_dbo_TblProduct.BondAmtMin)<>[dbo_TblProductVersion].[BondAmtMin]) AND
((DEV_dbo_TblProduct.Attachments)=IIf(Nz([dbo_tblProductversion]![Attachments],0)=-1,"Y","N")
And
(DEV_dbo_TblProduct.Attachments)<>"[dbo_tblProductVersion].[Attachments]")
AND
((DEV_dbo_TblProduct.EAndOFlag)=IIf(Nz([dbo_tblProductversion]![EAndOFlag],0)=-1,"Y","N")
And (DEV_dbo_TblProduct.EAndOFlag)<>"[dbo_tblProductVersion].[EAndOFlag]"))
OR (((DEV_dbo_TblProduct.BondAmtStd)<>[dbo_TblProductVersion]![BondAmtStd])
AND ((DEV_dbo_TblProduct.CategoryId)<>[dbo_tblObligationType].[CategoryID])
AND
((DEV_dbo_TblProduct.RenewalMethod)<>[dbo_TblProductVersion].[RenewalMethod])
AND
((DEV_dbo_TblProduct.FormId)<>[dbo_TblProductVersion].[NewBusinessFormId]))
OR (((DEV_dbo_TblProduct.BondAmtMax)<>[dbo_TblProductVersion].[BondAmtmax])
AND ((DEV_dbo_TblProduct.RateCode)<>[dbo_TblProductVersion].[RateCode]) AND
((DEV_dbo_TblProduct.Description)<>[dbo_TblProductVersion].[Description])) OR
(((DEV_dbo_TblProduct.BondType) Not Like [dbo_tblObligationType].[BondType])
AND ((DEV_dbo_TblProduct.CancelDays)<>[dbo_TblProductVersion].[CancelDays])
AND
((DEV_dbo_TblProduct.ObligationTypeID)<>[dbo_TblProduct].[ObligationTypeID])
AND
((DEV_dbo_TblProduct.BondObligationDescription)<>[dbo_TblProduct].[BondObligationDescription])
AND
((DEV_dbo_TblProduct.SpecialInstructions)<>[dbo_TblProductVersion].[SpecialInstructions]))
OR
(((DEV_dbo_TblProduct.BondTermMonths)<>[dbo_TblProductVersion].[BondTermMonths]) AND ((DEV_dbo_TblProduct.ObligeeId)<>[dbo_TblProduct].[ObligeeId]))
WITH OWNERACCESS OPTION;
has changed in one filed or even all seven if they have changed to be updated
into my source table. The problem is the source table has a primary key but
it is not necessary to update that field of course. How would I go about
setting up the query to make this happen. I have tried everything from not
show or moving th primay key to checking all properites etc.All tables are
included in the query set. Here is my SQL if needed. Thank you in advance!
UPDATE dbo_tblSaaDocument RIGHT JOIN (dbo_tblObligationType INNER JOIN
(dbo_TblProductVersion INNER JOIN (DEV_dbo_TblProduct RIGHT JOIN
dbo_TblProduct ON DEV_dbo_TblProduct.ProductId = dbo_TblProduct.ProductId) ON
dbo_TblProductVersion.ProductId = dbo_TblProduct.ProductId) ON
dbo_tblObligationType.ObligationTypeID = dbo_TblProduct.ObligationTypeID) ON
dbo_tblSaaDocument.SaaDocumentID = dbo_tblObligationType.SaaDocumentID SET
DEV_dbo_TblProduct.ProductId = [dbo_tblProduct]![ProductID],
DEV_dbo_TblProduct.StateAbbr = [dbo_TblProduct]![StateAbbr],
DEV_dbo_TblProduct.ProductLine = [dbo_tblObligationType]![ProductLine],
DEV_dbo_TblProduct.BondAmtStd = [dbo_TblProductVersion]![BondAmtStd],
DEV_dbo_TblProduct.BondAmtMax = [dbo_TblProductVersion]![BondAmtMax],
DEV_dbo_TblProduct.BondType = [dbo_tblObligationType]![BondType],
DEV_dbo_TblProduct.BondTermMonths = [dbo_TblProductVersion]![BondTermMonths],
DEV_dbo_TblProduct.CancelDays = [dbo_TblProductVersion]![CancelDays],
DEV_dbo_TblProduct.ObligationTypeID = [dbo_TblProduct]![ObligationTypeID],
DEV_dbo_TblProduct.CategoryId = [dbo_tblObligationType]![CategoryID],
DEV_dbo_TblProduct.BondExpirationDate =
[dbo_TblProductVersion]![BondExpirationDate],
DEV_dbo_TblProduct.AvailableOnline = [dbo_TblProduct]![Available Online],
DEV_dbo_TblProduct.MinCreditScore = [dbo_TblProductVersion]![MinCreditScore],
DEV_dbo_TblProduct.BondEffectiveDate =
[dbo_TblProductVersion]![BondEffectiveDate], DEV_dbo_TblProduct.ClassCode =
[dbo_tblSaaDocument]![ClassCode], DEV_dbo_TblProduct.RiskType =
[dbo_TblProductVersion]![RiskType], DEV_dbo_TblProduct.RateType =
[dbo_TblProductVersion]![RiskType], DEV_dbo_TblProduct.RenewalMethod =
[dbo_TblProductVersion]![RenewalMethod], DEV_dbo_TblProduct.RateCode =
[dbo_TblProductVersion]![RateCode],
DEV_dbo_TblProduct.BondObligationDescription =
[dbo_TblProduct]![BondObligationDescription], DEV_dbo_TblProduct.ObligeeId =
[dbo_TblProduct]![ObligeeID], DEV_dbo_TblProduct.SpecialInstructions =
[dbo_TblProductVersion]![SpecialInstructions], DEV_dbo_TblProduct.Description
= [dbo_tblProductVersion].[Description], DEV_dbo_TblProduct.FormId =
[dbo_tblProductVersion].[NewBusinessFormId], DEV_dbo_TblProduct.BondAmtMin =
[dbo_TblProductVersion]![BondAmtMin], DEV_dbo_TblProduct.Attachments =
[dbo_TblProductVersion].[Attachments], DEV_dbo_TblProduct.Countersignatures =
[dbo_TblProductVersion].[Countersignatures], DEV_dbo_TblProduct.EAndOFlag =
[dbo_TblProductVersion].[EAndOFlag]
WHERE (((DEV_dbo_TblProduct.ProductId)<>[dbo_tblProduct]![ProductID])) OR
(((DEV_dbo_TblProduct.StateAbbr)<>[dbo_tblProduct].[Stateabbr]) AND
((DEV_dbo_TblProduct.Countersignatures)=IIf(Nz([dbo_tblProductversion]![Countersignatures],0)=-1,"Y","N")
And
(DEV_dbo_TblProduct.Countersignatures)<>"[dbo_tblProductVersion].[Countersignatures]"))
OR (((DEV_dbo_TblProduct.ProductLine) Not Like
[dbo_tblObligationType].[ProductLine]) AND
((DEV_dbo_TblProduct.BondExpirationDate)<>[dbo_TblProductVersion].[BondExpirationDate])
AND ((DEV_dbo_TblProduct.AvailableOnline)<>[dbo_TblProduct].[Available
Online]) AND
((DEV_dbo_TblProduct.MinCreditScore)<>[dbo_TblProductVersion].[MinCreditScore])
AND
((DEV_dbo_TblProduct.BondEffectiveDate)<>[dbo_TblProductVersion].[BondEffectiveDate])
AND ((DEV_dbo_TblProduct.ClassCode)<>[dbo_tblSaaDocument].[ClassCode]) AND
((DEV_dbo_TblProduct.RiskType)<>[dbo_TblProductVersion].[RiskType]) AND
((DEV_dbo_TblProduct.RateType)<>[dbo_TblProductVersion]![RateType]) AND
((DEV_dbo_TblProduct.BondAmtMin)<>[dbo_TblProductVersion].[BondAmtMin]) AND
((DEV_dbo_TblProduct.Attachments)=IIf(Nz([dbo_tblProductversion]![Attachments],0)=-1,"Y","N")
And
(DEV_dbo_TblProduct.Attachments)<>"[dbo_tblProductVersion].[Attachments]")
AND
((DEV_dbo_TblProduct.EAndOFlag)=IIf(Nz([dbo_tblProductversion]![EAndOFlag],0)=-1,"Y","N")
And (DEV_dbo_TblProduct.EAndOFlag)<>"[dbo_tblProductVersion].[EAndOFlag]"))
OR (((DEV_dbo_TblProduct.BondAmtStd)<>[dbo_TblProductVersion]![BondAmtStd])
AND ((DEV_dbo_TblProduct.CategoryId)<>[dbo_tblObligationType].[CategoryID])
AND
((DEV_dbo_TblProduct.RenewalMethod)<>[dbo_TblProductVersion].[RenewalMethod])
AND
((DEV_dbo_TblProduct.FormId)<>[dbo_TblProductVersion].[NewBusinessFormId]))
OR (((DEV_dbo_TblProduct.BondAmtMax)<>[dbo_TblProductVersion].[BondAmtmax])
AND ((DEV_dbo_TblProduct.RateCode)<>[dbo_TblProductVersion].[RateCode]) AND
((DEV_dbo_TblProduct.Description)<>[dbo_TblProductVersion].[Description])) OR
(((DEV_dbo_TblProduct.BondType) Not Like [dbo_tblObligationType].[BondType])
AND ((DEV_dbo_TblProduct.CancelDays)<>[dbo_TblProductVersion].[CancelDays])
AND
((DEV_dbo_TblProduct.ObligationTypeID)<>[dbo_TblProduct].[ObligationTypeID])
AND
((DEV_dbo_TblProduct.BondObligationDescription)<>[dbo_TblProduct].[BondObligationDescription])
AND
((DEV_dbo_TblProduct.SpecialInstructions)<>[dbo_TblProductVersion].[SpecialInstructions]))
OR
(((DEV_dbo_TblProduct.BondTermMonths)<>[dbo_TblProductVersion].[BondTermMonths]) AND ((DEV_dbo_TblProduct.ObligeeId)<>[dbo_TblProduct].[ObligeeId]))
WITH OWNERACCESS OPTION;