1.安装Oracle客户端,并配置好tns
2.sql server中建立链接服务器
/****** Object: LinkedServer [LINKOEMREP2] Script Date: 07/28/2011 10:30:08 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'LINKOEMREP2', @srvproduct=N'oracle', @provider=N'MSDAORA', @datasrc=N'OEMREP2'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'LINKOEMREP2',@useself=N'False',@locallogin=NULL,@rmtuser=N'You_Username',@rmtpassword='########'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'LINKOEMREP2', @optname=N'use remote collation', @optvalue=N'true'
3.使用openquery读取oracle中database数据
SELECT * from openquery(LinkOEMREP2, 'SELECT * from prd.F_tb F_tb')