If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Depending on what SQL engine you are using the LEFT function may do what you want
eg select left(<mycolumn>,20) as <myColumnsFirst20Characters> from <mytable>
Is taking part in the 'Distinguished Gentlemans' ride. Being neither distinguished nor a gentleman, but I am keen to raise funds for Prostrate Cancer research. At present I'm threatening to ride a Norton 961 wearing a kilt. If you would like to contribute to Prostrate Cancer research then please consider donating via this page:- http://www.gentlemansride.com/rider/healdem
This should also be the most efficient way of doing things since CAST is not a scalar function but a built-in functionality.
Of course, most people will use a scalar function like SUBSTR, SUBSTRING or LEFT, but for one thing these names are not standardised so your SQL becomes less portable, and secondly there may be a performance hit when calling scalar functions.
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting