Load data from Microsoft SQL Server

This article explains how to connect to Microsoft SQL Server with Exasol and then load data.

To view details about data type mappings or to migrate data, see the SQL Server to Exasol migration script in our GitHub repository.

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

To add the JDBC driver, create a configuration file called settings.cfg with the following settings:

Microsoft JDBC driver

DRIVERNAME=MSSQLServer
PREFIX=jdbc:sqlserver:
FETCHSIZE=100000
INSERTSIZE=-1

jTDS JDBC driver

DRIVERNAME=jtdssqlserver
PREFIX=jdbc:jtds:sqlserver:
FETCHSIZE=100000
INSERTSIZE=-1

Follow the procedure described in Add JDBC Driver to upload the settings.cfg configuration and JDBC driver files to Exasol.

For additional information, refer to the JTDS Driver section in this Exasol Knowledge Base article that describes best practices for using 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.

See also

For additional information, see Best Practices for IMPORT/EXPORT with SQL Server.