# CMS.MERGE

```json metadata
{
  "title": "CMS.MERGE",
  "description": "Merges several sketches into one sketch",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "arguments": [{"name":"destination","type":"key"},{"name":"numKeys","type":"integer"},{"multiple":true,"name":"source","type":"key"},{"arguments":[{"name":"weights","token":"WEIGHTS","type":"pure-token"},{"multiple":true,"name":"weight","type":"double"}],"name":"weight","optional":true,"type":"block"}],
  "syntax_fmt": "CMS.MERGE destination numKeys source [source ...] [WEIGHTS weight\n  [weight ...]]",
  "complexity": "O(n) where n is the number of sketches",
  "group": "cms",
  "acl_categories": ["@cms","@write"],
  "since": "2.0.0",
  "tableOfContents": {"sections":[<li>[{"id":"parameters","title":"Parameters:"}]},{"id":"examples","title":"Examples"},{"id":"redis-enterprise-and-redis-cloud-compatibility","title":"Redis Enterprise and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"}]}
}
```













Merges several sketches into one sketch. All sketches must have identical width and depth. Weights can be used to multiply certain sketches. Default weight is 1. 

### Parameters:

* **dest**: The name of destination sketch. Must be initialized. 
* **numKeys**: Number of sketches to be merged.
* **src**: Names of source sketches to be merged.
* **weight**: Multiple of each sketch. Default =1.

## Examples

```
redis> CMS.MERGE dest 2 test1 test2 WEIGHTS 1 3
OK
```

## Redis Enterprise and Redis Cloud compatibility

| Redis<br />Enterprise | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
|:----------------------|:-----------------|:------|
| <span title="Supported">&#x2705; Supported</span><br /> | <span title="Supported">&#x2705; Flexible & Annual</span><br /><span title="Supported">&#x2705; Free & Fixed</nobr></span> |  |

## Return information

{{< multitabs id="cms-merge-return-info" 
    tab1="RESP2" 
    tab2="RESP3" >}}

One of the following:

* [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) `OK` if executed correctly.
* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: non-existent key or destination key is not of the same width and/or depth.

-tab-sep-

One of the following:

* [Simple string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-strings) `OK` if executed correctly.
* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: non-existent key or destination key is not of the same width and/or depth.

