Load data from Microsoft SQL Server
Learn how to connect to Microsoft SQL Server with Exasol and then load data.
Prerequisites
-
The SQL Server system must be reachable from the Exasol system.
-
The user credentials in the connection must be valid.
Download driver
-
Download the JDBC driver for SQL Server from Microsoft JDBC download . To know which JDBC driver is compatible with your database version, refer to the JDBC driver support matrix and policy .
-
You can also use the jTDS driver, which is an open source Java type 4 JDBC driver for Microsoft SQL Server, to connect to Exasol. You can download the jTDS driver for SQL Server from the Sourceforge website.
Add JDBC driver
-
Create a configuration file
settings.cfgwith the following settings:Microsoft JDBC driver
CopyDRIVERNAME=MSSQLServer
PREFIX=jdbc:sqlserver:
FETCHSIZE=100000
INSERTSIZE=-1jTDS JDBC driver
CopyDRIVERNAME=jtdssqlserver
PREFIX=jdbc:jtds:sqlserver:
FETCHSIZE=100000
INSERTSIZE=-1The file must end with an empty line (line break followed by zero characters).
-
Upload the settings.cfg file and the driver .jar file to BucketFS in the Exasol cluster.
In Exasol 2025.1 and later you can upload files using Exasol Admin. You can also use any compatible file transfer tool, including curl on the command line. See also Manage files in BucketFS.
In Exasol SaaS you must upload the driver through the web console.
If the driver was downloaded as a .tar.gz or .zip archive, make sure that you extract and upload only the .jar file along with the settings.cfg file.
Example (using curl in Linux):
Copyexport WRITE_PW=<your_bucketfs_write_password>
export DATABASE_NODE_IP=<ip_address_of_cluster_node>
export PORT=<bucketfs_port> # default: 2581
curl -v --insecure -X PUT -T settings.cfg https://w:$WRITE_PW@$DATABASE_NODE_IP:$PORT/default/drivers/jdbc/exasol/settings.cfg
curl -v --insecure -X PUT -T exajdbc.jar https://w:$WRITE_PW@$DATABASE_NODE_IP:$PORT/default/drivers/jdbc/exasol/exajdbc.jarThe option
--insecureor-ktells curl to bypass the TLS certificate check. This option allows you to connect to a HTTPS server that does not have a valid certificate. Only use this option if certificate verification is not possible and you trust the server.
-
For more details about how to add JDBC drivers and configuration files, see Add JDBC driver.
-
To learn more about how to upload files to BucketFS, see Manage files in BucketFS.
-
For details about data type mappings and how to migrate data, see SQL Server to Exasol migration script on GitHub.
-
For additional information about best practices when exchanging data between Exasol and SQL Server, see Best Practices for IMPORT/EXPORT with SQL Server.
Connect using MSSQL JDBC driver
To create a connection, run the following statement. Replace the connection string and credentials as needed.
CREATE OR REPLACE CONNECTION JDBC_SQLSERVER
TO 'jdbc:sqlserver://192.168.99.100:1433;databaseName=MY_DATABASE;instance=v1'
USER 'user'
IDENTIFIED BY 'password';
To test the connection, run the following statement.
select * from
(
import from JDBC at JDBC_SQLSERVER
statement 'select ''Connection works'' '
);
Connect using jTDS JDBC driver
The jTDS connection string format used to connect to SQL Server is as follows:
jdbc:jtds:sqlserver://{SERVER_NAME}/{DATABASE_NAME);instance={INSTANCE}
To create a connection, run the following statement. Replace the connection string and credentials as needed.
CREATE OR REPLACE CONNECTION JDBC_SQLSERVER
TO 'jdbc:jtds:sqlserver://192.168.99.100:1433/MY_DATABASE;instance=v1'
USER 'username'
IDENTIFIED BY 'password';
To test the connection, run the following statement:
select * from
(
import from JDBC at JDBC_SQLSERVER
statement 'select ''Connection works'' '
);
Windows authentication
You can use Windows authentication in conjunction with the jTDS driver by adding the parameters useNTLMv2=true and domain=[domain name]. For example:
CREATE OR REPLACE CONNECTION JDBC_SQLSERVER
TO 'jdbc:jtds:sqlserver://192.168.99.100:1433/MY_DATABASE;domain=AD;useNTLMv2=true;'
USER 'username' -- Windows username
IDENTIFIED BY 'password' --Windows password;
Load data
Use IMPORT to load data from a table or SQL statement using the connection that you created.