(A)同一服务器上连接不同的数据库
DBF.dbo.Table_NAME
DBF 数据库名
dbo 是必须写的
Table_NAME 连接的表名
例 1:
select a.k_teacherid ,a.b_cystatus,b.k_name,c.school_name
from b_shouinform a,k_teacher b,charge_kindergarten.dbo.DIC_SCHOOL_NAME c
where c.school_code=b.k_schoolid and a.k_teacherid=b.k_teacherid and b_iid='62'
例 2:
select * from charge_kindergarten.dbo.DIC_SCHOOL_NAME a,kinder.dbo.k_teacher b
where a.school_code=b.k_schoolid
(B)不同服务器连接
lssjx 当前服务器上表
select * from lssjx where saveid in
(
select user_id from opendatasource
('SQLOLEDB',
'server=192.168.0.2;uid=sa;pwd=;database=zxx').zxx.dbo.teach
)
//////////////////////////服务器上ip---server=192.168.0.2
///////所要连接的数据库-------database=zxx
,(zxx.dbo.teach 数据库中的teach表)
posted on 2008-10-06 10:24
毒毒 阅读(1108)
评论(0) 编辑 收藏