Q:

Sybase binary conversion to Teradata

I have a SQL query below
select convert(binary(20),convert(char(20),'-'))

The output is:
2D20202020202020202020202020202020202020
Would like to ask the Teradata equivalent of it. 
below is my query
TO_BYTES(CAST ( LPAD('-', 20, '-') AS VARCHAR(20)) , 'ASCII' )

But it is resulting me in output:
2D-2D-2D-2D-2D-2D-2D-2D-00-00-00-00-00-00-00-00-00-00-00-00
Note: hyphen or - is okay with Teradata, as long as the output is 2D-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20-20

A:

Your result doesn't match your query, but you're using the wrong approach anyway :-)
LPAD adds leading characters, you need RPAD instead, trailing characters.
TO_BYTES( RPAD('-', 20) , 'ASCII' )

Btw, the hyphen is just for making the display of binary data more readable. It's a client setting, e.g in SQL Assistant: Tools -> Options -> Data Format -> Display dashes between bytes for binary data values

