---
title: "TO_BINARY"
description: "La funci\u00F3n SQL TO_BINARY convierte un valor en un BLOB."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/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/es/
---

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

## Propósito
La función SQL `TO_BINARY` convierte un valor en un BLOB. El texto se interpreta como UTF-8.

Véanse también [[ASCII_TO_BLOB]], [[UNICODE_TO_BLOB]] y [[HEX_TO_BLOB]].

Parámetros:
- Entrada (`ANY`): valor que se va a convertir.

Devuelve: la entrada convertida en un BLOB.

## Ejemplos
El siguiente ejemplo convierte el texto `hi` en un BLOB y recupera la representación en base64:
```sql
select base64_encode(to_binary('hi'))

-------------------
aGk=
```
El siguiente ejemplo convierte el texto `abc` en un BLOB y recupera la longitud en bytes:
```sql
select length(to_binary('abc'))

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

