Microsoft SQL (MS SQL) Server is a popular Relational Database Management System (RDBMS) used by small and large businesses. It can store and retrieve data as requested by software applications.
You can ingest data from your MS SQL Server using Hevo Pipelines and replicate it to a warehouse of your choice.
Prerequisites
Perform the following steps to configure your Generic MS SQL Source:
Enable TCP/IP Protocol
You need to configure the MS SQL Server instance with TCP port value 1433 to enable Hevo to connect to your MS SQL Server.
Follow these steps to enable TCP/IP protocol for your MS SQL Server:
1. Enable the TCP/IP port
-
Open the SQL Server Configuration Manager.
-
In the left navigation pane under SQL Server Network Configuration, click Protocols for <MS SQL Server Instance Name>. The default instance name is MSSQLSERVER.
-
In the right pane, right click the TCP/IP Protocol Name, and select Enable (if not enabled already) in the Status field.
-
Click OK to acknowledge the dialogue box that warns you to restart the services for the changes to take effect.
2. Verify the TCP/IP port
Follow these steps to check the port where TCP/IP is enabled:
-
Right-click the TCP/IP Protocol Name, and select Properties.
-
In the TCP/IP Properties window, click the IP Addresses tab.
-
In the IPAII section, ensure the TCP Port value is 1433, which is the default port for MS SQL Server.
-
Click OK to acknowledge the dialogue box that warns you to restart the services for the changes to take effect.
-
Click OK, and exit the TCP/IP Properties window.
3. Restart the MS SQL Server instance
-
In the left navigation pane, click SQL Server Services.
-
In the right pane, right-click your < MS SQL Server Instance Name >, and select Restart.
Enable Change Tracking
Note: This step is valid only for Pipelines with Change Tracking as their ingestion mode.
The Change Tracking mechanism captures the database changes. To enable or disable change tracking, the database user must have the ALTER DATABASE privilege.
To enable change tracking, connect your SQL Server database to your SQL Client tool and enter these commands:
-
Enable change tracking at the database level:
ALTER DATABASE <database_name> SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 3 DAYS, AUTO_CLEANUP = ON)
The CHANGE_RETENTION
value specifies the duration for which change tracking information is retained. You can use AUTO_CLEANUP
to enable or disable the cleanup task that removes old change tracking information. Read Enable Change Tracking for a Database.
Note: Hevo recommends that you set the CHANGE_RETENTION value to 3 DAYS. This reduces the risk of log expiry in the case of Pipelines having a low ingestion frequency, for example, 24 hours.
-
Enable change tracking at the table level:
ALTER TABLE <schema_name>.<table> ENABLE CHANGE_TRACKING
Repeat this step for each table you want to replicate using Change Tracking. Read Enable Change Tracking for a Table.
Note: Hevo does not support Change Data Capture (CDC) for SQL Server.
Create a Database User and Grant Privileges
1. Create a database user (Optional)
Note: Skip this step if you are using an existing database user.
Perform the following steps to create a user in your SQL Server database:
Note: Replace the placeholder values in the commands below with your own. For example, <username> with hevo.
-
Connect to your SQL Server database as an admin user with an SQL client tool, such as sqlcmd.
-
Select the database:
-
Create a login and a database user:
CREATE LOGIN <username> WITH PASSWORD = '<password>';
CREATE USER <username> FOR LOGIN <username>;
2. Grant privileges to the user
The database user specified in the Hevo Pipeline must have the following global privileges:
To set up these privileges, connect your MS SQL Server in your SQL Client tool, and enter these commands:
Note: Replace the placeholder values in the commands below with your own. For example, <username> with hevo.
-
Grant SELECT
privilege at the database level:
GRANT SELECT ON DATABASE::<database> TO <username>;
-
Grant SELECT
privilege at the schema level:
GRANT SELECT ON SCHEMA::<schema_name> TO <username>;
-
If the ingestion mode is Change Tracking, grant the VIEW CHANGE TRACKING
privilege at the schema or table level:
-
For schema level:
GRANT VIEW CHANGE TRACKING ON SCHEMA::<schema_name> TO <username>;
-
For table level:
GRANT VIEW CHANGE TRACKING ON OBJECT::<schema_name>.<table_name> TO <username>;
Specify Generic SQL Server Connection Settings
Perform the following steps to configure SQL Server as a Source in Hevo:
-
Click PIPELINES in the Navigation Bar.
-
Click + CREATE PIPELINE in the Pipelines List View.
-
On the Select Source Type page, select SQL Server.
-
On the Configure your SQL Server Source page, specify the following:
-
Pipeline Name: A unique name for the Pipeline, not exceeding 255 characters.
-
SQL Server Host: SQL Server host’s IP address or DNS.
The following table lists a few examples of SQL Server hosts:
Variant |
Host |
Amazon RDS SQL Server |
ms-sql-server-1.xxxxx.rds.amazonaws.com |
Azure MS SQL |
mssql.database.windows.net |
Generic MS SQL |
10.123.10.001 or mssql.westeros.inc |
Google Cloud SQL Server |
35.220.150.0 |
Note: For URL-based hostnames, exclude the http:// or https:// part. For example, if the hostname URL is https://mssql.database.windows.net, enter mssql.database.windows.net.
-
SQL Server Port: The port on which your SQL Server is listening for connections. Default value: 1433.
-
SQL Server User: The read-only user who has the permissions to read tables in your database.
-
SQL Server Password: The password for the read-only user.
-
Select an Ingestion Mode: The desired mode by which you want to ingest data from the Source. You can expand this section by clicking SEE MORE to view the list of ingestion modes to choose from. Default value: Change Tracking. The available ingestion modes are Change Tracking, Table, and Custom SQL.
Depending on the ingestion mode you select, you must configure the objects to be replicated. Refer to section, Object and Query Mode Settings for the steps to do this.
Note: For Custom SQL ingestion mode, all Events loaded to the Destination are billable.
-
Database Name: The database that you wish to replicate.
-
Schema Name: The schema that holds the tables to be replicated. Default value: dbo.
-
Connect through SSH: Enable this option to connect to Hevo using an SSH tunnel, instead of directly connecting your SQL Server database host to Hevo. This provides an additional level of security to your database by not exposing your SQL Server setup to the public. Read Connecting Through SSH.
If this option is disabled, you must whitelist Hevo’s IP addresses. Refer to the content for your SQL Server variant for steps to do this.
-
Advanced Settings:
-
Include New Tables in the Pipeline: Applicable for all ingestion modes except Custom SQL. If enabled, Hevo automatically ingests data from tables created after the Pipeline has been built. If disabled, the new tables are listed in the Pipeline Detailed View in Skipped state, and you can manually include the ones you want and load their historical data. You can include these objects post-Pipeline creation to ingest data.
You can change this setting later.
-
Click TEST CONNECTION. This button is enabled once you specify all the mandatory fields. Hevo’s underlying connectivity checker validates the connection settings you provide.
-
Click TEST & CONTINUE to proceed for setting up the Destination. This button is enabled once you specify all the mandatory fields.
Object and Query Mode Settings
Once you have specified the Source connection settings in Step 4 above, do one of the following:
-
For Pipelines configured with the Change Tracking ingestion mode:
-
On the Select Objects page, select the objects you want to replicate.
-
Click CONTINUE. This button is enabled once you select at least one object for which Change Tracking is enabled.
Note:
-
Each object represents a table in your database.
-
You must enable Change Tracking for the objects you want to ingest data from. If disabled, Hevo adds these objects to your Pipeline in the SKIPPED state.
-
For customers signing up after Release 2.19, Hevo automatically uses the Unique Incrementing Append Only (UIAO) query mode for the objects that contain a unique column. For the others, it ingests data using the Full Load query mode.
-
For Pipelines configured with the Table ingestion mode:
-
On the Select Objects page, select the objects you want to replicate and click CONTINUE.
Note: Each object represents a table in your database.
-
On the Configure Objects page, specify the query mode you want to use for each selected object.
-
For Pipelines configured with the Custom SQL ingestion mode:
-
On the Provide Query Settings page, enter the custom SQL query to fetch data from the Source.
-
In the Query Mode drop-down, select the query mode, and click CONTINUE.
Data Replication
For Teams Created |
Default Ingestion Frequency |
Minimum Ingestion Frequency |
Maximum Ingestion Frequency |
Custom Frequency Range (in Hrs) |
Before Release 2.21 |
15 Mins |
5 Mins |
24 Hrs |
1-24 |
After Release 2.21 |
6 Hrs |
30 Mins |
24 Hrs |
1-24 |
Note: The custom frequency must be set in hours as an integer value. For example, 1, 2, or 3 but not 1.5 or 1.75.
- Historical Data: In the first run of the Pipeline, Hevo ingests all available data for the selected objects from your Source database.
- Incremental Data: Once the historical load is complete, data is ingested as per the ingestion frequency.
Read the detailed Hevo documentation for the following related topics:
Error 1003 - Authentication error
Potential Causes
- The credentials of the database user authorizing the connection are incorrect.
Suggested Actions
-
Verify that the password entered in the Configure your Source page for the authorizing user is correct.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1005 - Connection timeout
Potential Causes
- The database connection details are incorrect.
- Hevo’s IP addresses are not whitelisted.
Suggested Actions
-
Verify that the Database name entered in the Configure your Source page is correct.
-
Verify that the Database Port entered in the Configure your Source page is correct.
-
Verify that Hevo’s IP addresses for your region are whitelisted. Refer to the following for more information:
-
Set permissions for the respective SQL Server Source variant as follows:
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1006 - Insufficient access
Potential Causes
- Hevo’s IP addresses are not whitelisted.
Suggested Actions
Error 1011 - Access denied
Potential Causes
- The username or password is incorrect.
Suggested Actions
-
Verify that the Database user entered in the Configure your Source page is correct.
-
Verify that the Database password entered in the Configure your Source page is correct.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Connecting to a Local Database
Refer to this section for steps to connect to your local database. For detailed information and troubleshooting help, read Connecting to a LocalHost Database.
Prerequisites
-
MY-SQL/MS-SQL service is running on your local machine.
-
Data to be loaded to the Destination is available in your MY-SQL/MS-SQL database.
-
You have an account on ngrok and an installed ngrok utility on your local machine. To run ngrok on your local machine, follow these one-time steps:
-
Extract the ngrok utility:
-
On Linux or MacOS, unzip ngrok from a terminal:
-
On Windows, double-click ngrok.zip to extract it.
-
Authenticate ngrok in your local machine:
./ngrok authtoken <your_auth_token>
You can get the auth token from your ngrok dashboard. For example, in the image below, the auth_token starts with 1t7uGaJshUvnh2Fg1MApl
.
Connect to the local database
Perform the following steps to connect to the local database:
-
Log in to your database server.
-
Start a TCP tunnel forwarding to your database port.
./ngrok tcp <your_database_port>
For example, the port address for MySQL is 3306. Therefore, the command would be:
-
Copy the public IP address (hostname and port number) for your local database and port. For example, in the image below, 8.tcp.ngrok.io
is the database hostname and 19789
is the port number.
-
Paste the hostname and port number into the Database Host and Database Port fields respectively.
-
Specify all other settings and click TEST & CONTINUE.
Limitations
- Hevo does not support data replication from temporary tables and views.
See Also
Revision History
Refer to the following table for the list of key updates made to this page:
Date |
Release |
Description of Change |
Apr-29-2024 |
NA |
Updated section, Specify Generic SQL Server Connection Settings to include more detailed steps. |
Mar-05-2024 |
2.21 |
Added the Data Replication section. |
Feb-27-2024 |
NA |
Updated sections, Enable Change Tracking, Create a database user, and Grant privileges to the user as per the latest Hevo functionality. |
Jan-15-2024 |
NA |
Updated section, Limitations to add information about Hevo not supporting data replication from certain tables. |
Jan-10-2024 |
2.19 |
Updated section, Object and Query Mode Settings as per the latest Hevo functionality. |
Nov-03-2023 |
NA |
Added section, Object and Query Mode Settings. |
Oct-27-2023 |
NA |
Added subsection, Create a database user. |
Apr-21-2023 |
NA |
Updated section, Specify Generic SQL Server Connection Settings to add a note to inform users that all loaded Events are billable for Custom SQL mode-based Pipelines. |
Mar-09-2023 |
2.09 |
Updated section, Specify Generic SQL Server Connection Settings to mention about SEE MORE in the Select an Ingestion Mode section. |
Dec-19-2022 |
2.04 |
Updated section, Specify Generic SQL Server Connection Settings to add information that you must specify all fields to create a Pipeline. |
Dec-07-2022 |
2.03 |
Updated section, Specify Generic SQL Server Connection Settings to mention about including skipped objects post-Pipeline creation. |
Dec-07-2022 |
2.03 |
Updated section, Specify Generic SQL Server Connection Settings to mention about the connectivity checker. |
Apr-21-2022 |
1.86 |
Updated section, Specify Generic SQL Server Connection Settings. |
Sep-08-2021 |
NA |
- Updated the fourth list item under Prerequisites - Updated sub-section Grant privileges to the user. |
Jul-26-2021 |
1.68 |
Added a note for the SQL Server Host field. |
Jul-12-2021 |
1.67 |
Added sections: - Specify Generic MS SQL Connection Settings - Connecting to a Local Database. |
Mar-09-2021 |
1.58 |
Replaced references to Logical Replication with Change Tracking as Change Tracking is a distinct Pipeline mode for SQL Server Source types. |