Does teradata support LeftB function

Database
Enthusiast

Does teradata support LeftB function

Our data in database contain Chinese characters, you know, one Chinese character contain 2 bytes, and we want to format selected field to 5 bytes length. I think I need some function like "LeftB" in Teradata to get charaters out by bytes.
If we can have some function like "LeftB", another question is for how to avoid half split a Chinese character. At the end of string, if we split the Chinese character we will have un-readable character at the end. At this situation, we'd like to cut 1 more byte to cut the whole chinese character out, and link a blank at the end.
4 REPLIES
rgs
Enthusiast

Re: Does teradata support LeftB function

I think you would be better off defining your column as a Unicode column. That way you avoid such problems as splitting a Chinese character in half since a Unicode character is two bytes.

Look at the substring function for extracting a string out of a longer string, if you still want extract a substring.
Enthusiast

Re: Does teradata support LeftB function

The backgroud is :
The data store in our system, and the database is Teradata, we need to use SQL extract data out and generate a text file as a interface file with other system, this "other" system is not under our control, and we must follow strict file format provided by "other" syterm's vendor. Each field in the interface file must has fixed width.
Enthusiast

Re: Does teradata support LeftB function

Any one can help?
Teradata Employee

Re: Does teradata support LeftB function

Hello,

For that i guess your best option will be to write a UDF for this functionality.

Regards,

Adeel