---
title: "TO_BINARY"
description: "SQL-funktionen TO_BINARY konverterer en v\u00E6rdi til en BLOB."
language: da
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/da/docs/invantive-universalsql/grammar/sql-functions/to-binary
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/to-binary
updated: 2026-12-04T14:35:50Z
license: https://documentation.invantive.eu/da/
---

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

## Formål
SQL-funktionen `TO_BINARY` konverterer en værdi til en BLOB. Tekst fortolkes som UTF-8.

Se også [[ASCII_TO_BLOB]], [[UNICODE_TO_BLOB]] og [[HEX_TO_BLOB]].

Parametre:
- Input (`ANY`): værdi, der skal konverteres.

Returnerer: input konverteret til en BLOB.

## Eksempler
Følgende eksempel konverterer teksten `hi` til en BLOB og henter base64-repræsentationen:
```sql
select base64_encode(to_binary('hi'))

-------------------
aGk=
```
Følgende eksempel konverterer teksten `abc` til en BLOB og henter længden i bytes:
```sql
select length(to_binary('abc'))

-------------------
3
```

