Left Join bring in data except for FK column, why?

  • Hello, I'm needing help, again.

    I have a stage table, gets populated, has two columns name1, and name2.
    I have dimension table 3 columns, 1 identity, and col1 and col2.
    I have a production table, I created it to be near mirror of stage table, and with an alter add constraint and Foreign key geo_id, and references the dimension tables PK geo_id.

    Now the Issue, when I run the Insert/Select to load the Stage to the Production, all the data loads, except the FK geo_id in the production table, it's all NULLS. This is a sample of that insert script:

    insert into [dbo].[Production_Table]select a.[col1] , a.[col2] , b.[geo_id]from [dbo].[STAGE] Aleft outer join [dbo].[dimgeography] Bon a.[name1] = b.[name1]and a.[name2] = b.[name2]

    If I change to Right Join it will populate the geo_id column correctly, but none of the other columns will populate.

    What am I doing wrong here?

    Thanks

  • Turns out that when I pop'd the two varchar(35) cols, I crossed then on the insert, and that was the issue.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply