View Single Post
  #1 (permalink)  
Old January 8th, 2007, 01:33 PM
Hadware Hadware is offline
Registered User
 
Join Date: Nov 2003
Location: Canton, OH, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hadware Send a message via Yahoo to Hadware
Default Calling on a database within a stored procedure

Hi,
I am working with multiple databases on a server.
What I am attempting is to get data from two databases on one stored procedure.
Here is an example of what I'm trying to do:
create procedure sp_procedure
(
@variable int
)
declare @anothervariable char(3)
select @anothervariable = afield from atable where something = @variable
use dbo.@anothervariable
select anotherfield from anothertable where somethingelse = @variable

The afield column contains the database name.
What method within the stored procedure can I use to get to the other database?

Thanks,
Eric

Reply With Quote