SQL SERVER LTRIM,RTRIM STRING FUNCTIONS
LTRIM removes leading spaces from string
RTRIM removes trailing spaces from string
select len(' hello'),ltrim(' hello'),len(ltrim(' hello'))
O/P:
select len(' hello') length,ltrim(' hello') ltrim,len(ltrim(' hello')) [length after l trim]
length ltrim length after l trim
6 hello 5
6 hello 5
select ltrim(' hello '), len(' hello '),len(ltrim(' hello '))
hello 6 5
ltrim removes all leading blanks, len ignors trailing blanks ,so length will be 6 & 5
EX: Remove all blanks and find length of the String in T-SQL
I/P: ' hello this is New York, may god bless u '
set @str= ' hello this is New York, may god bless u '
select len(@str) length, ltrim(rtrim(@str)) [after trim],len(ltrim(rtrim(@str))) [after trim length]
O/P:
length after trim after trim length
41 hello this is New York, may god bless u 39
Tags:SQL SERVER LTRIM, SQL SERVER RTRIM STRING FUNCTIONS,SQL SERVeR LEN STring function, trim and find length in SQL SERVER
No comments:
Post a Comment