May 29, 2003 at 8:58 am
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.
May 29, 2003 at 9:04 am
You must have fields with the same name on the two tables, refer them :
tablename1.myfield
tablename2.myfield
Luani
Luani
May 29, 2003 at 9:09 am
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.)
May 29, 2003 at 9:14 am
SElect tb1.*,tb2.* from db1.table1 tb1 join db2.table2 tb2 on tb1.myfield=tb2.myfield
Luani
Luani
May 29, 2003 at 9:16 am
Correction:
db1.table1 is db1..table1
db1.table2 is db1..table2
Luani
Luani
May 29, 2003 at 9:17 am
Got it! Thanks for the assist!
May 29, 2003 at 9:22 am
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