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 |
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-01-29 : 14:13:16
|
I have a stored procedure that I need to get working and have searched with no luck on how to do this.The sp is in one database and it does a simple select from a table.I need to do a union on another table that is in a seperate database but the same server....Select * from myTable Where myField = 1UNION Select * from myOtherDatabase.myOtherTable Where myOtherField = 1 How can I access the other database?Thanks,Zath |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-01-29 : 14:16:12
|
Never fails.... I found it.databaseName.dbo.tableNameZath |
 |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-01-29 : 14:17:34
|
Select * from myTable Where myField = 1UNION Select * from myOtherDatabase..myOtherTable Where myOtherField = 1You will need permission on the other table for the the user that runs the sp.The syntax is db.owner.tableTry it first with no owner as I have in your statement - that will default to dbo or the user.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|