我正在使用OpenQuery
从 Oracle 表中获取行集到我的 SQL Server 中。然后我发现有一些东西被称为OPENROWSET
获取所有行
但它对我没有用。
SELECT a.*
FROM OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=INDIANBANK;UID=ags;PWD=mypass',
'Select * From ATM_PROGNOSIS.IR_ATMMON_AGS') AS a
错误 :-
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()).".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".
我的 DSN 名称:印度银行
我已使用Microsoft OLE DB Provider for ODBC Driver创建链接服务器以连接到 oracle (ORACLE DB 位于远程服务器上)
我的 DSN 显示测试连接成功。与我的链接服务器相同。
当我执行以下查询时Select * From openquery(IndianBank,'Select * From ATM_PROGNOSIS.IR_ATMMON_AGS')
它只检索一行
我的链接服务器代码:-
EXEC master.dbo.sp_addlinkedserver @server = N'INDIANBANK', @srvproduct=N'IndianBankOracle', @provider=N'MSDASQL', @datasrc=N'INDIANBANK'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'INDIANBANK',@useself=N'False',@locallogin=NULL,@rmtuser=N'ags',@rmtpassword='########'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'collation compatible', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIANBANK', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO