{"id":3443,"date":"2014-01-07T11:29:06","date_gmt":"2014-01-07T11:29:06","guid":{"rendered":"http:\/\/www.oratraining.com\/blog\/?p=3443"},"modified":"2014-01-08T15:08:05","modified_gmt":"2014-01-08T15:08:05","slug":"steps-by-step-connecting-to-microsoft-sql-database-from-oracle-database-using-database-gateway-for-sql-server","status":"publish","type":"post","link":"https:\/\/www.oratraining.com\/blog\/2014\/01\/steps-by-step-connecting-to-microsoft-sql-database-from-oracle-database-using-database-gateway-for-sql-server\/","title":{"rendered":"Steps-by-step: Connecting to Microsoft SQL Server database from Oracle using Database Gateway for SQL Server"},"content":{"rendered":"<p>Starting with 11g Oracle now provides a Database Gateway for MS SQL Server and various other databases.<\/p>\n<p>The gateway is certified with Oracle database release 10.1.0.5, 10.2.0.3 after applying the gateway compatibility patch bug or you can directly use it with Oracle RDBMS 10.2.0.4, 10.2.0.5, 11.1 and 11.2<\/p>\n<p>&nbsp;<\/p>\n<p>Following steps are involved. Please note that this steps are shown for Linux\/Unix platform but for Windows also similar steps are to be followed.<\/p>\n<ol>\n<li>Download Oracle Database Gateways CD if you have not already installed it<\/li>\n<li>Install Oracle Database Gateway for Microsoft SQL Server<\/li>\n<li>Configure Database Gateway for Microsoft SQL Server (DG4MSQL)<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><strong>Download the software<\/strong><\/p>\n<p>Download Oracle Database Gateways from Oracle eDelivery site.<\/p>\n<p><a href=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/dg4msql-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3446\" alt=\"dg4msql-1\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/dg4msql-1.png\" width=\"709\" height=\"569\" srcset=\"https:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/dg4msql-1.png 709w, https:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/dg4msql-1-300x240.png 300w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Install Oracle Database Gateway for Microsoft SQL server<\/strong><\/p>\n<p>Unzip the downloaded zip file. It will create a directory named<strong> &#8220;gateways&#8221;<br \/>\n<\/strong><\/p>\n<p>Change the directory to <strong>gateways<\/strong> and start installer.<\/p>\n<p>&nbsp;<\/p>\n<p>-bash-3.00$ <strong>cd \/software\/11gR2-Gateways\/gateways\/<br \/>\n<\/strong><\/p>\n<p>-bash-3.00$ <strong>.\/runInstaller<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep2.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep3.png\" \/><\/p>\n<p>Click <strong>Next<\/strong><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep4.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Select name for the Oracle Home. The Path defaults to Oracle Home. No need to change the same.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep5.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep6.png\" \/><\/p>\n<p>Select <strong>Oracle Database Gateway for Microsoft SQL Server<\/strong> and click <strong>Next<\/strong><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep7.png\" \/><\/p>\n<p>Provide any existing Microsoft SQL Server details where you are planning to connect. It actually writes this in a config file and does not really verify.<\/p>\n<p>This can be changed later also in the configuration file. Click <strong>Next<\/strong><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep8.png\" \/><\/p>\n<p>Click <strong>Install<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep9.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep10.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Once it prompts with above screen, open another shell and run the script as root<\/p>\n<p>root@host # <strong>\/app\/oracle\/product\/11.2.0\/dbhome_1\/root.sh<\/strong><\/p>\n<p>Running Oracle 11g root.sh script&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>The following environment variables are set as:<\/p>\n<p>ORACLE_OWNER= ora11g<\/p>\n<p>ORACLE_HOME= \/app\/oracle\/product\/11.2.0\/dbhome_1<\/p>\n<p>&nbsp;<\/p>\n<p>Enter the full pathname of the local bin directory: [\/usr\/local\/bin]:<\/p>\n<p>The file &#8220;dbhome&#8221; already exists in \/usr\/local\/bin. Overwrite it? (y\/n) [n]: y<\/p>\n<p>Copying dbhome to \/usr\/local\/bin &#8230;<\/p>\n<p>The file &#8220;oraenv&#8221; already exists in \/usr\/local\/bin. Overwrite it? (y\/n) [n]: y<\/p>\n<p>Copying oraenv to \/usr\/local\/bin &#8230;<\/p>\n<p>The file &#8220;coraenv&#8221; already exists in \/usr\/local\/bin. Overwrite it? (y\/n) [n]: y<\/p>\n<p>Copying coraenv to \/usr\/local\/bin &#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>Entries will be added to the \/var\/opt\/oracle\/oratab file as needed by<\/p>\n<p>Database Configuration Assistant when a database is created<\/p>\n<p>Finished running generic part of root.sh script.<\/p>\n<p>Now product-specific root actions will be performed.<\/p>\n<p>Finished product-specific root actions.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"http:\/\/www.oratraining.com\/blog\/wp-content\/uploads\/2014\/01\/010714_1128_Stepsbystep11.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Click <strong>Exit<\/strong> to Finish the installation.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 13pt;\"><strong>Configure Oracle Database Gateway for Microsoft SQL Server<br \/>\n<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Make sure that the MS SQL database details are correct in the dg4msql parameter file.<\/p>\n<p>&nbsp;<\/p>\n<p>-bash-3.00$ <strong>more $ORACLE_HOME\/dg4msql\/admin\/initdg4msql.ora<br \/>\n<\/strong><\/p>\n<p># This is a customized agent init file that contains the HS parameters<\/p>\n<p># that are needed for the Database Gateway for Microsoft SQL Server<\/p>\n<p>&nbsp;<\/p>\n<p>#<\/p>\n<p># HS init parameters<\/p>\n<p>#<\/p>\n<p>HS_FDS_CONNECT_INFO=[SERVER127]:4076\/\/NewCDP16<\/p>\n<p># alternate connect format is hostname\/serverinstance\/databasename<\/p>\n<p>HS_FDS_TRACE_LEVEL=OFF<\/p>\n<p>HS_FDS_RECOVERY_ACCOUNT=RECOVER<\/p>\n<p>HS_FDS_RECOVERY_PWD=RECOVER<\/p>\n<p>&nbsp;<\/p>\n<p>-bash-3.00$ <strong>cd $ORACLE_HOME\/network\/admin<\/strong><\/p>\n<p>Append following in existing <strong>listener.ora. <\/strong>Change the name, path and port as required.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>LISTENER_dg4mssql<\/strong>=<\/p>\n<p>(DESCRIPTION_LIST =<\/p>\n<p>(DESCRIPTION =<\/p>\n<p>(ADDRESS_LIST =<\/p>\n<p>(ADDRESS = (PROTOCOL = TCP)(HOST = &lt;oracle host or IP&gt;) (PORT = &lt;any unused port&gt;))<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>SID_LIST_LISTENER_dg4mssql<\/strong>=<\/p>\n<p>(SID_LIST=<\/p>\n<p>(SID_DESC=<\/p>\n<p>(SID_NAME=dg4msql)<\/p>\n<p>(ORACLE_HOME=\/app\/oracle\/product\/11.2.0\/dbhome_1)<\/p>\n<p>(ENV=&#8221;LD_LIBRARY_PATH=\/app\/oracle\/product\/11.2.0\/dbhome_1\/dg4msql\/driver\/lib:\/app\/oracle\/product\/11.2.0\/dbhome_1\/lib&#8221;)<\/p>\n<p>(PROGRAM=dg4msql)<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Start the newly created listener.<br \/>\n<\/strong><\/p>\n<p>-bash-3.00$ <strong>lsnrctl start LISTENER_dg4mssql<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Verify that the service is registered with the listener .<br \/>\n<\/strong><\/p>\n<p>-bash-3.00$ <strong>lsnrctl status LISTENER_dg4mssql<\/strong><\/p>\n<p>\u2026<\/p>\n<p>Listening Endpoints Summary&#8230;<\/p>\n<p>(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=&lt;oracle hostname or IP&gt;)(PORT=1551)))<\/p>\n<p>Services Summary&#8230;<\/p>\n<p>Service &#8220;dg4msql&#8221; has 1 instance(s).<\/p>\n<p>Instance &#8220;dg4msql&#8221;, status UNKNOWN, has 1 handler(s) for this service&#8230;<\/p>\n<p>The command completed successfully<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Append following in tnsnames.ora<br \/>\n<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>dg4msql =<\/p>\n<p>(DESCRIPTION=<\/p>\n<p>(ADDRESS=(PROTOCOL=tcp)(HOST=&lt; oracle hostname or IP &gt;)(PORT=1551))<\/p>\n<p>(CONNECT_DATA=(SID=dg4msql))<\/p>\n<p>(HS=OK)<\/p>\n<p>)<\/p>\n<p>&nbsp;<\/p>\n<p>-bash-3.00$ <strong>tnsping dg4msql<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>TNS Ping Utility for Solaris: Version 11.2.0.1.0 &#8211; Production on 07-JAN-2014 12:30:08<\/p>\n<p>&nbsp;<\/p>\n<p>Copyright (c) 1997, 2009, Oracle. All rights reserved.<\/p>\n<p>&nbsp;<\/p>\n<p>Used parameter files:<\/p>\n<p>\/app\/oracle\/product\/11.2.0\/dbhome_1\/network\/admin\/sqlnet.ora<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Used TNSNAMES adapter to resolve the alias<\/p>\n<p>Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=&lt;host&gt;)(PORT=1551)) (CONNECT_DATA=(SID=dg4msql)) (HS=OK))<\/p>\n<p>OK (0 msec)<\/p>\n<p>&nbsp;<\/p>\n<p>Create a new database link pointing to this TNS using SQL Server login credentials. This username must be already created in the Microsoft SQL Server database.<\/p>\n<p>&nbsp;<\/p>\n<p>SQL&gt; <strong>CREATE DATABASE LINK sqlserver CONNECT TO &#8220;SQLUser&#8221; IDENTIFIED BY &#8220;SQLPass&#8221; USING &#8216;dg4msql&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Database link created.<\/p>\n<p>&nbsp;<\/p>\n<p>SQL&gt; <strong>select count(1) from &#8220;SQLView&#8221;@sqlserver;<br \/>\n<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>COUNT(1)<\/p>\n<p>&#8212;&#8212;&#8212;-<\/p>\n<p>24592<\/p>\n<p>&nbsp;<\/p>\n<p>This concludes setup steps to Read data of Microsoft SQL server table from Oracle database.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting with 11g Oracle now provides a Database Gateway for MS SQL Server and various other databases. The gateway is certified with Oracle database release 10.1.0.5, 10.2.0.3 after applying the gateway compatibility patch bug or you can directly use it with Oracle RDBMS 10.2.0.4, 10.2.0.5, 11.1 and 11.2 &nbsp; Following steps are involved. Please note [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3443","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts\/3443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/comments?post=3443"}],"version-history":[{"count":7,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts\/3443\/revisions"}],"predecessor-version":[{"id":3451,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/posts\/3443\/revisions\/3451"}],"wp:attachment":[{"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/media?parent=3443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/categories?post=3443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oratraining.com\/blog\/wp-json\/wp\/v2\/tags?post=3443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}