Loading Data from Microsoft SQL Server

This section explains how to connect 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.

Additionally, 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.

Download driver

Add JDBC driver

To add a JDBC driver, you must create a configuration file called settings.cfg. Use the below settings to create the file, replacing the JAR entry with the name of the jar file you downloaded:

Microsoft JDBC driver

DRIVERNAME=MSSQLServer
JAR=mssql-jdbc-11.2.0.jre8.jar
DRIVERMAIN=com.microsoft.sqlserver.jdbc.SQLServerDriver
PREFIX=jdbc:sqlserver:
NOSECURITY=NO
FETCHSIZE=100000
INSERTSIZE=-1

jTDS JDBC driver

DRIVERNAME=jtdssqlserver
JAR=jtds-1.3.1.jar
DRIVERMAIN=net.sourceforge.jtds.jdbc.Driver
PREFIX=jdbc:jtds:sqlserver:
NOSECURITY=NO
FETCHSIZE=100000
INSERTSIZE=-1

Follow the procedure described in Add JDBC Drivers to upload the settings.cfg configuration file and the JDBC driver jar file(s).

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

Examples:

To create a connection, use the following statement:

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, use 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}

Examples:

To create a connection, use the following statement:

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, use 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].

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

You can use the IMPORT statement to load data using the connection you created above. IMPORT supports loading data from a table or a SQL statement.

See also

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