120 pts.
 Accessing another database using a variable
I have a select like this: SELECT a.part_id, a.descript, b.location from PART_MASTER a, anotherdatabase.INVENTORY b where a.part_id = b.part_id Is it possible to use a @variable to identify the other database, rather than hard coding it? (I've tried @db2.INVENTORY b) but SQL SERVER 2000 doesn't like that.

Software/Hardware used:
ASKED: October 9, 2008  4:22 PM
UPDATED: October 10, 2008  6:00 AM

Answer Wiki:
In order to do this you have to use dynamic SQL. Flame gave a good answer to this <a href="http://itknowledgeexchange.techtarget.com/itanswers/sql-server-2000-connection-to-multiple-databases-using-variables">same question</a>.
Last Wiki Answer Submitted:  October 10, 2008  6:00 am  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _