Ambiguous column name

  • Forgive me if this question seems simplistic (my strengths are VB, HTML/ASP, and structured programming, not T-SQL).

    I'm trying to perform a join on tables (in different databases on the same server), and I'm continually getting "Ambiguous column name."

    WHY AM I GETTING THIS?!? My SQL references and MSDN are completely useless in explaining what this is and what would generate it.

  • You must have fields with the same name on the two tables, refer them :

    tablename1.myfield

    tablename2.myfield

    Luani


    Luani

  • Trouble is, the fields **ARE** the same name. (I'm assuming "fields" and "columns" are interchangable in this context.)

    As an experiment, I tried performing a join on another table in the same database using a different column name (that happens to hold the same data), and it worked fine.

    Can a join be performed between tables on different databases? (Note that, as I mentioned before, the databases reside on the same server.)

  • SElect tb1.*,tb2.* from db1.table1 tb1 join db2.table2 tb2 on tb1.myfield=tb2.myfield

    Luani


    Luani

  • Correction:

    db1.table1 is db1..table1

    db1.table2 is db1..table2

    Luani


    Luani

  • Got it! Thanks for the assist!

  • You are welcome!:)

    Luani


    Luani

Viewing 7 posts - 1 through 6 (of 6 total)

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