MERGE [dbo].[RoutingRules] AS T
    USING (VALUES (@WorkspaceId, @RulesJson)) AS S([WorkspaceId], [RulesJson])
    ON T.[WorkspaceId] = S.[WorkspaceId]
    WHEN MATCHED THEN
UPDATE
    SET T.[RulesJson] = S.[RulesJson]
    WHEN NOT MATCHED THEN
INSERT
(
[WorkspaceId],
[RulesJson])
VALUES (S.[WorkspaceId], S.[RulesJson]);
