Forum Discussion
Stefanssce
Sep 12, 2023Copper Contributor
SQL Server 2022 create external data source with Oracle TNS files (introduced with CU2)
Hi, I am trying to set up an external data source to connect to Oracle. This works fine when I specify the Oracle hostname like "LOCATION = 'oracle://oracle1:1521". In our setup we normally us ...
- Sep 12, 2023After a lot of try and error I managed to get it working. Here the example which might help others:
--SQL
CREATE EXTERNAL DATA SOURCE OracleSource
WITH ( LOCATION = 'oracle://ORA_TEST' , connection_options = 'ServerName=ORA_TEST;TNSNamesFile=C:\ORA\TNS_ADMIN\tnsnames.ora',
PUSHDOWN = ON,
CREDENTIAL = cred_oracle)
--TNSNAMES.ORA which is store in C:\ORA\TNS_ADMIN
ORA_TEST =
(DESCRIPTION =
(CONNECT_TIMEOUT = 3)
(ENABLE = BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.yourdomain.net )(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle2.yourdomain.net )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORA_TEST)
)
)
Stefanssce
Sep 12, 2023Copper Contributor
After a lot of try and error I managed to get it working. Here the example which might help others:
--SQL
CREATE EXTERNAL DATA SOURCE OracleSource
WITH ( LOCATION = 'oracle://ORA_TEST' , connection_options = 'ServerName=ORA_TEST;TNSNamesFile=C:\ORA\TNS_ADMIN\tnsnames.ora',
PUSHDOWN = ON,
CREDENTIAL = cred_oracle)
--TNSNAMES.ORA which is store in C:\ORA\TNS_ADMIN
ORA_TEST =
(DESCRIPTION =
(CONNECT_TIMEOUT = 3)
(ENABLE = BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.yourdomain.net )(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle2.yourdomain.net )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORA_TEST)
)
)
--SQL
CREATE EXTERNAL DATA SOURCE OracleSource
WITH ( LOCATION = 'oracle://ORA_TEST' , connection_options = 'ServerName=ORA_TEST;TNSNamesFile=C:\ORA\TNS_ADMIN\tnsnames.ora',
PUSHDOWN = ON,
CREDENTIAL = cred_oracle)
--TNSNAMES.ORA which is store in C:\ORA\TNS_ADMIN
ORA_TEST =
(DESCRIPTION =
(CONNECT_TIMEOUT = 3)
(ENABLE = BROKEN)
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.yourdomain.net )(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle2.yourdomain.net )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORA_TEST)
)
)