1

I am trying to convert an integer to binary. Here is my code

create table test
(test varbinary(8));

insert into test 
select int_to_string(7, binary) as test;

Here is the error that I get:

ERROR [HY000] ERROR: A size must be specified for a varying binary attribute.

Rajat Mishra
  • 3,635
  • 4
  • 27
  • 41
Peyman
  • 91
  • 1
  • 4

1 Answers1

0
  1. per the answer proposed by ScottMcG to user3206440's related question I think it is better to use varchar(8) to store the data instead of varbinary.
  2. per @rajat-mishra's hint, your insert statement should be:

    insert into test select int_to_string(7, 2) as test;

Community
  • 1
  • 1
tipanverella
  • 3,477
  • 3
  • 25
  • 41