Features Tutorials

Connecting DataGrip to MS SQL Server

Some specific needs of SQL developers like connecting to SQL Server from OSX and even using Windows authentication can be covered by DataGrip. Since releasing DataGrip, we’ve received lots of comments about connecting to SQL Server. It appears it’s not straightforward as with other databases, requiring a couple of extra steps beforehand. Here is a small guide describing the main problems you may face and how to solve them.

Configure the SQL Server Configuration Manager

To open SQL Server Configuration Manager, open the Search dialog on Windows and type SQLServerManager14.msc (for Microsoft SQL Server 2017). Double-click the found result. If you use other versions of Microsoft SQL Server, change the second digit before .msc:

  • SQLServerManager13.msc for SQL Server 2016

  • SQLServerManager12.msc for SQL Server 2014

  • SQLServerManager11.msc for SQL Server 2012

db_tutorial_open_sql_server_configuration_manager

Run the SQL Server Browser

SQL Server Browser listens for incoming requests and provides information about Microsoft SQL Server instances on the computer. For more information about SQL Server Browser, see SQL Server Browser in the Microsoft documentation.

If the SQL Server Browser menu items are disabled, try to enable the SQL Server Agent service.

  1. In the SQL Server Configuration Manager, click SQL Server Services.

  2. In the right pane that lists server services, right-click SQL Server Browser and select Start.

db_tutorial_run_sql_server_browser

Enable SQL Server Agent

If the SQL Server Browser is running, you can skip this procedure.

SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks. For more information about these services, see SQL Server Agent in the official Microsoft documentation. Ensure that SQL Server Agent is running and starts automatically. After the change, a restart might be required.

  1. Navigate to Control Panel | Administrative Tools | Services.

  2. In the Services window, right-click SQL Server Agent(<server_name>) and select Properties. For this tutorial, <server_name> is MSSQLSERVER.

  3. From the Startup type list, select Automatic and click Start.

db_tutorial_run_sql_server_agent

Enable the TCP/IP connection

  1. In the SQL Server Configuration Manager, expand SQL Server Configuration and click Protocols for MSSQLSERVER, where MSSQLSERVER is a name of the Microsoft SQL Server instance.

  2. In the list of protocol names, right-click TCP/IP and select Properties.

  3. On the Protocol tab, from the Enabled list, select Yes.

  4. On the IP Addresses tab, find the interface that your workstation uses and see the connection port. By default, the port is 1433. Verify that other running applications do not use the same port.

db_tutorial_enable_tcp_ip

If you changed any settings, restart the server. For most situations, the restart resolves connection problems.

Connect to Microsoft SQL Server with DataGrip

We’ll describe configuration of DataGrip on WindowsmacOS, and Linux. Note that the Use Windows domain authentication checkbox is available only on Windows. To configure Windows domain authentication on macOS and Linux, see Connect by using Windows domain authentication.

Connect by using SQL Server authentication

  1. Navigate to File | Data Sources

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. At the bottom of the data source settings area, click the Download missing driver files link. Alternatively, you can specify user drivers for the data source. For more information about user drivers, see Add a user driver to an existing connection.

  4. In HostInstance, and Port fields, specify your connection details.

  5. Clear the Use Windows domain authentication checkbox.

  6. In User and Password fields, specify your credentials.

  7. To ensure that the connection to the data source is successful, click Test Connection.

db_tutorial_connect_by_using_sql_server_authentication

Connect by using single sign-on for Microsoft SQL Server

If you run DataGrip on Windows in the same domain as the Microsoft SQL Server database, you can use the Single-Sign On (SSO).

  1. Navigate to File | Data Sources.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. At the bottom of the data source settings area, click the Download missing driver files link. Alternatively, you can specify user drivers for the data source. For more information about user drivers, see Add a user driver to an existing connection.

  4. From the Authentication list, select Windows credentials.

  5. To ensure that the connection to the data source is successful, click Test Connection.

Connect by using SQL Server authentication

Connect by using Windows domain authentication

Windows

  1. Navigate to File | Data Sources

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. At the bottom of the data source settings area, click the Download missing driver files link. Alternatively, you can specify user drivers for the data source. For more information about user drivers, see Add a user driver to an existing connection.

  4. In HostInstance, and Port fields, specify your connection details.

  5. Ensure that the Use Windows domain authentication checkbox is selected.

  6. To ensure that the connection to the data source is successful, click Test Connection.

db_tutorial_connect_by_using_windows_domain_authentication

macOS and Linux

  1. Navigate to File | Data Sources 

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. From the Driver list, select Microsoft SQL Server (jTds).

  4. At the bottom of the data source settings area, click the Download missing driver files link. Alternatively, you can specify user drivers for the data source. For more information about user drivers, see Add a user driver to an existing connection.

  5. In HostInstance, and Port fields, specify your connection details.

  6. From the Authentication list, select Domain credentials.

  7. In the Domain field, specify the domain (for example, DEVELOPMENT).

  8. In User and Password fields, specify your domain credentials. In the User field, type your domain user without the domain prefix (for example, John.Smith instead of DOMAIN\John.Smith).

    Alternatively, on the General tab, specify the connection string. Consider the following example of a full connection string:

    jdbc:jtds:sqlserver://UNIT-670:1433;domain=DEVELOPMENT;instance=MSSQLSERVER;databaseName=guest;
    Copied!
  9. To ensure that the connection to the data source is successful, click Test Connection.

Connect by using SQL Server authentication

Choose databases and schemas

If you want to check which particular databases or schemas are shown in the database view, go to the Schemas tab in data source properties:

Screenshot 2019-09-09 16.31.18

Or click on the n of m  text area near the data source name in the database explorer.

Screenshot 2019-09-09 16.31.38

All selected databases and schemas will appear in the database view.

That’s it! If you are experiencing any other problems, please tweet @ us or create an issue in our youtrack.

Also, you may be interested in our blog-post caled Transition from SSMS to DataGrip.

Your DataGrip Team

The Drive to Develop

image description