Link_Ora =(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.1.106)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = ETMCDB))
)..........................................D:\oracle\product\10.2.0\client_1\BIN>tnsping Link_OraTNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on ..............................D:\oracle\product\10.2.0\client_1\BIN>sqlplus system/oracle@Link_OraSQL*Plus: Release 10.2.0.1.0 - Production on ..............................Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL>Start --> Control Panel--> Services: to make sure "Distributed Transaction Coordinator" is starting3. windows ODBCStart --> Control Panel --> Computer Management --> ODBC --> Tab (User DNS or System DNS) --> Add (Microsoft ODBC for oracle) --> Name (Same as the name in tnsnames.ora:Link_Ora) --> Server name (Same as the name in tnsnames.ora:Link_Ora)-->Finish4. DB_Link in SQL ServerIn General Tab
Link_ Name: Other Data Source Link: Microsoft OLE DB Provider for Oracle Product name: Oracle Data_ Source: the Name in ODBC Link_Ora (step 3) User ID=username;Password=userpasswd or UID=username;PWD=userpasswd (the username / password in Oracle)In Security Tab:
Select the last option: enter the username / password in OracleOr to use SQL:
ADD: EXEC sp_addlinkedserver 'Link_Ora', 'Oracle', 'Link_Ora ', 'Server name or IP' EXEC sp_addlinkedserver 'Link_Ora', 'Oracle', 'Link_Ora ', 'ETMCDB' EXEC sp_addlinkedsrvlogin @rmtsrvname='Link_Ora',@useself='false',@locallogin='sa',@rmtuser='sys',@rmtpassword='oracle'or 'Link_Ora','false',null,'rmtuser','rmtpassword' DEL: IF EXISTS (SELECT srvname FROM master.dbo.sysservers srv WHERE srvid != 0 AND srvname = N'DB_Link_Name') EXEC master.dbo.sp_dropserver @server=N'DB_Link_Name', @droplogins='droplogins'Testing:
SELECT * FROM Link_Ora .ERP.BAS_ITEM_CLASS SELECT * FROM openquery(OraTest,'SELECT * FROM OraTest.ERP.BAS_ITEM_CLASS ')Ref:
http://www.west263.com/www/info/50399-1.htm http://www.cnblogs.com/jjiac/archive/2008/07/03/1234643.html http://www.mssqlcity.com/FAQ/Replic/LinkSetRepl.htmhttp://www.cnblogs.com/studyzy/archive/2006/12/08/690307.htmlhttp://space.itpub.net/?uid-7728585-action-viewspace-itemid-470225
转载于:https://www.cnblogs.com/buro79xxd/archive/2009/11/23/1682566.html