• SQLisAwE5OmE (2/4/2016)


    Sean Lange (2/4/2016)


    SQLisAwE5OmE (2/4/2016)


    Hi Sean,

    I tried your query, and I am getting the following error.

    Msg 4104, Level 16, State 1, Line 43

    The multi-part identifier "pa.ParentID" could not be bound.

    Msg 207, Level 16, State 1, Line 43

    Invalid column name 'ParentID'.

    Msg 4104, Level 16, State 1, Line 45

    The multi-part identifier "pa.ParentID" could not be bound.

    Msg 4104, Level 16, State 1, Line 36

    The multi-part identifier "pa.ParentID" could not be bound.

    Let me know if you need the create script for any other table.

    Did you see my comment?

    select pa.ParentID --no clue what the primary key is for this so I am guessing

    I have no idea what the key is. I am a bit scared that you can't convert that into your environment. I get the feeling you don't understand this code and are just trying it out. The important part of this is understanding what the code is doing. Once that happens the adjustment should be simple.

    I understand the first part of the query.....second part I am confused

    There is no parent ID on Name table....

    The way you differentiate Parent1, parent2 is from Member_Type column

    Member_Type = MP, NM-MP = Parent1

    Member_Type = MSP, NP-SP = Parent2

    column ID is the primary key column.

    Right so change the code I took a shot in the dark with and replace ParentID with column(s) that are your primary key. I guess ID?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/