0

I have a Fact_Actuals yable with a new column "Segment_Id".

I need to insert the segment id from DimsegmentMaster into Fact_Actuals.

Link is with SegmentMaster and Source Table column.

Link is with FactTable is Measures of the Source Table column below.

Kindly provide me the update query, as my below query is not fine.

UPDATE Application_DB.[cdw].[Fact_Actuals] set segment_sid = (SELECT c.SID FROM Application_DB.[cdw].[Fact_Actuals] b inner join Source_DB.STA.SourceTable a ON convert(decimal(20,10),LTRIM(RTRIM(a.[K308]))) = b.NetExternalSales and convert(decimal(20,10),LTRIM(RTRIM(a.[K203]))) = b.Quantity_CON and convert(decimal(20,10),LTRIM(RTRIM(a.[K202]))) = b.Quantity_KG inner join Application_DB.cdw.DimSegmentMaster c ON RTRIM(a.[C005])=c.SegmentOriginal ) 

1 Answer 1

1

Try this:

UPDATE b set segment_sid = c.sid FROM Application_DB.[cdw].[Fact_Actuals] b inner join Source_DB.STA.SourceTable a ON convert(decimal(20,10),LTRIM(RTRIM(a.[K308])))=b.NetExternalSales and convert(decimal(20,10),LTRIM(RTRIM(a.[K203])))=b.Quantity_CON and convert(decimal(20,10),LTRIM(RTRIM(a.[K202])))=b.Quantity_KG inner join Application_DB.cdw.DimSegmentMaster c ON RTRIM(a.[C005])=c.SegmentOriginal 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.