Environment is Oracle 10g,
Function is TRIM()
==================
Trim spaces from both side
SELECT LTRIM(' salman ') FROM dual; Result (without quotes) => 'salman '
SELECT RTRIM(' salman ') FROM dual; Result (without quotes) => ' salman'
Trimming characters: (I enjoyed it:) )
SELECT TRIM ('S' FROM 'SSSALMANSSS') FROM dual; Result (without quotes) => 'ALMAN'
Comments: 'S' trimmed from both side of string
SELECT TRIM ( LEADING 'S' FROM 'SSSALMANSSS') FROM dual; Result (without quotes) => 'ALMANSSS'
Comments: 'S' trimmed from start of string
SELECT TRIM ( TRAILING 'S' FROM 'SSSALMANSSS') FROM dual; Result (Without quotes') => 'SSSALMAN'
Comments: 'S' trimmed from end of string
And last one for clarification only
SELECT TRIM ( 'S' FROM ' SSSALMANSSS ') FROM dual; Result (without quotes) => ' SSSALMANSSS '
Comment : Nothing trimmed, reason is that leading and trailing characters are white spaces, so if you want to trim character, first use TRIM() to eliminate spaces, then trim characters.
You can bind DataView directly with Grid, without writing code for "string manipulation" in C# :)
Enjoy..........
what about triming special characters , any thougt about that
ReplyDeleteHi Salman
ReplyDeleteYou can use Ltrim and Ttrim as follows as well:
select RTRIM(LTRIM(' salman ')) from dual and the result will be spaces trimmed from both sides in one single sql.
Regards
Qaiser