Skip to main content
Operational data in SQL Server is often the source of truth for orders, payments and inventory, but it is not built for heavy analytical queries. In this walkthrough you replicate a SQL Server table into ClickHouse with an automated pipeline: Striim loads the existing rows, then streams every insert, update and delete as it happens. You then query the result in ClickHouse. See Introducing Automated Pipelines for Effortless Data Replication for a full walkthrough. SQL Server CDC requires the Striim for ClickHouse Premium plan.

What you will build

SQL Server (sales.orders) > Striim initial load, then CDC > ClickHouse (sales.orders, ReplacingMergeTree)

Before you begin

  • A running Striim for ClickHouse service on the Premium plan (see Get started).
  • A SQL Server instance reachable from Striim, with SQL Server Agent running, and permission to enable change data capture. The steps below work on SQL Server on a VM or Amazon RDS for SQL Server.
  • A ClickHouse service, a database named sales, a Striim user with the required privileges, and a ClickHouse connection profile.

Step 1: Prepare SQL Server

Create a database and a sample table with a few rows. This seed data is illustrative so that you can reproduce the example.
Enable change data capture on the database and create a user for Striim. Striim enables CDC on each selected table when the application starts.
Create the Striim user in salesdb:
SQL Server authentication mode must be enabled for the Striim user. Striim documents db_owner for the reader user. After your pipeline starts, you can confirm CDC is active with EXEC sys.sp_cdc_help_change_data_capture. See Configuring SQL Server to use MS SQL Reader for Azure VM prerequisites and Always On availability groups.

Step 2: Create the automated pipeline

  1. In Striim, select Apps > Create an App.
  2. Search for and select SQL Server as the source. Select ClickHouse as the target.
  3. Select Get Started and choose the automated pipeline (initial load plus CDC).
  4. Name the pipeline, for example SqlServerToClickHouse, choose a namespace, and select Next.
  5. Enter the SQL Server connection details: host and port (<host>:1433), database name salesdb, and the striim user. Select Next. Striim validates the connection. If validation fails, select Back and correct the settings; you must pass validation to continue.
  6. Select the schemas to replicate. Choose sales; do not select system schemas.
  7. Select the tables to replicate from each schema. Choose orders.
  8. Select your ClickHouse connection profile and set Table Engine to ReplacingMergeTree. This engine suits CDC sources that send a full row image on update.
  9. Optionally edit the table mapping. Confirm sales.orders maps to sales.orders in ClickHouse.
  10. Review the settings and select Save & Start.
Review the SQL Server to ClickHouse automated pipeline configuration Example wizard review. For this walkthrough, use salesdb, sales.orders and ReplacingMergeTree as described above. Striim creates two linked applications. It runs the initial load first, quiesces it when all rows are copied, then starts the CDC application automatically and shows event counts as changes flow. If either phase hits a problem, the pipeline halts and shows recommended fixes. Monitor the running change data capture application
Do not run DDL against the source tables while the initial load is running, and make sure SQL Server retains the change data (default retention is three days) from the start of the initial load until the CDC application has caught up.

Step 3: Verify the initial load in ClickHouse

Striim created the target table with the ReplacingMergeTree engine and two metadata columns. Inspect it:
Based on the Striim data type mapping, expect order_id and customer_id as Int32, status as String, total as Decimal(10, 2), placed_at as DateTime64, the columns __STRIIM_VERSION (UInt64) and __STRIIM_ISDELETED (UInt8), ENGINE = ReplacingMergeTree(__STRIIM_VERSION, __STRIIM_ISDELETED) and ORDER BY order_id.
You should see the three rows loaded from SQL Server.

Step 4: Stream changes

Make changes in SQL Server:
Run the same query in ClickHouse again. Orders 1, 2 and 4 should be present, order 2 should show SHIPPED, and order 3 should be absent. The delete is stored as a soft-delete row. The query uses FINAL to select the latest version and __STRIIM_ISDELETED = 0 to exclude deleted rows. Delete markers are retained by default; background merges alone do not guarantee their physical removal. See ReplacingMergeTree for cleanup behavior. You can also watch event counts and target freshness in the Striim monitoring view, or ask Clara for the current lag.

Build the same pipeline with Striim Clara

Instead of the wizard, you can describe the pipeline on the Home page, for example: “Build a pipeline from SQL Server to ClickHouse with initial load and change data capture for the sales.orders table.” Clara asks for the connection details, generates a TQL plan, and deploys only after you select Accept TQL.

Clean up

  • Stop and undeploy the two Striim applications from the Apps page.
  • SQL Server keeps capturing change data even after you undeploy the Striim applications with the default reader settings. To stop capturing data for this sample, run sys.sp_cdc_disable_table for sales.orders, or sys.sp_cdc_disable_db if no other tables in the database require CDC. See the SQL Server documentation for details. Alternatively, follow Striim’s Auto Disable Table CDC procedure.
  • Drop the sample tables: DROP TABLE sales.orders; in both systems.

Next steps