---
title: "CSVENCODE"
description: "The CSVENCODE SQL function returns the input text encoded as CSV adhering to RFC 4180."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/csvencode
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/csvencode
updated: 2026-10-22T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> CSVENCODE[CSVENCODE]:::quoted
    CSVENCODE --> End((END))
```

## Purpose
The `CSVENCODE` SQL function returns the input text encoded as CSV adhering to [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180):
- field separator `,`
- record separator CR, LF and CR/LF
- quoting character `"`
- escaped quoting character `\"`
- no headers

See also [[CSVDECODE]].

Parameters:
- Input (`varchar2`): the input which will be encoded to CSV from text.

Returns: A text which is the input encoded as CSV as `varchar2`.

## Examples
The following example retrieves the CSV representation of the value `a,b,c,d`:
```sql
select csvencode('a,b,c,d')

----------------
"a,b,c,d"
```
The following example retrieves the CSV representation of the value `text`:
```sql
select csvencode('text')

----------------
text
```