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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 T-SQL across databases

Author  Topic 

inferno
Starting Member

2 Posts

Posted - 2002-08-08 : 19:48:44
Is it possible to write transact SQL to read/write across multiple databases??

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-08 : 19:51:52
Sure.

Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-08 : 19:59:35
You can refer to tables in other databases using 3 part naming

use pubs
go

select * from Northwind.dbo.Customers
go


HTH
Jasper Smith
Go to Top of Page

inferno
Starting Member

2 Posts

Posted - 2002-08-08 : 20:20:50
Can you go across databases in a stored procedure?

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-08 : 20:22:24
Sure.

Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-08-08 : 22:02:45
quote:

Sure.



I see a trend forming.

You can do across databases with the 3 part naming scheme like jasper stated.


create proc GetCustomers
as
select * from Northwind.dbo.Customers


You can also execute a procedure that resides in another database.

exec DB1.dbo.GetCustomers


hth,
Justin

Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-09 : 08:47:02
Sure
Go to Top of Page
   

- Advertisement -