Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Jim
Starting Member
12 Posts |
Posted - 2002-08-12 : 19:47:48
|
| I am attempting to get data out of two databases. The SQL 'USE' statement works in the query analyzer in switching databases. However, it does not work in a stored procedure or in a dynamic SQL statement from an ASP page. The ODBC error message is 'Changed database context'. Is there a secret to this? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-08-12 : 20:24:42
|
| Yes, it is the (rather well) documented three-part naming convention, and it goes like this:SELECT * FROM database.owner.tableSo if you want to select from database B while in database A:SELECT * FROM B..tableNameYou can leave the owner portion blank if the table is owned by dbo.See Books Online if you need more information.Edited by - robvolk on 08/12/2002 20:25:18 |
 |
|
|
Jim
Starting Member
12 Posts |
Posted - 2002-08-12 : 20:52:02
|
| robvolk, thanks, that was it. |
 |
|
|
|
|
|