---
title: concat_ws function
description: Learn the syntax of the concat\_ws function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/concat_ws
---

# `concat_ws` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the concatenation strings separated by `sep`.

## Syntax

```
concat_ws(sep [, expr1 [, ...] ])
```

## Arguments

* `sep`: An STRING expression.
* `exprN`: Each `exprN` can be either a STRING or an ARRAY of STRING.

## Returns

The result type is STRING.

If `sep` is NULL the result is NULL.
`exprN` that are NULL are ignored.
If only the separator is provided, or all `exprN` are NULL, an empty string.

## Examples

```sql
> SELECT concat_ws(' ', 'Spark', 'SQL');
  Spark SQL
> SELECT concat_ws('s');
  ''
> SELECT concat_ws(',', 'Spark', array('S', 'Q', NULL, 'L'), NULL);
  Spark,S,Q,L
```

## Related functions

* [`||` (pipe pipe sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/pipepipesign.md)
* [`concat` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/concat.md)
* [`array_join` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_join.md)
