---
title: "TO_BINARY"
description: "La funzione SQL TO_BINARY converte un valore in un BLOB."
language: it
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/it/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:55Z
license: https://documentation.invantive.eu/it/
---

## Sintassi
```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))
```

## Scopo
La funzione SQL `TO_BINARY` converte un valore in un BLOB. Il testo viene interpretato come UTF-8.

Vedi anche [[ASCII_TO_BLOB]], [[UNICODE_TO_BLOB]] e [[HEX_TO_BLOB]].

Parametri:
- Input (`ANY`): valore da convertire.

Restituisce: il valore di input convertito in un BLOB.

## Esempi
L'esempio seguente converte il testo `hi` in un BLOB e recupera la rappresentazione in base64:
```sql
select base64_encode(to_binary('hi'))

-------------------
aGk=
```
L'esempio seguente converte il testo `abc` in un BLOB e ne recupera la lunghezza in byte:
```sql
select length(to_binary('abc'))

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

