Wednesday 7 September 2011

SQL SERVER some String Functions


Select Ascii('A') // Output '65' get Ascii value of 'A' 


Select Char(97) //output 'a' get char value of 97 


Select Reverse('sample') //output 'elpmas' get the reverse value of string 


Select Substring('Hello World',3,5) //output 'llo w' 


Select Stuff('world',2,5,'welcome') //output 'wwelcomorlde' 

Here 2 --> Start Position 5 --> Replace Char Length 

Select Replicate('Hai ',3) //output 'Hai Hai Hai ' its 

repeat a Value 3 times Here 3 --> No.of Times 

Select Replace('abcdefgh','de','xy') //output 'abcxyfgh' 


Select Ltrim(' Hai ') //output 'Hai ' remove a space in front of the string 


Select Rtrim(' Hai ') //output ' Hai' remove a space in end of the string

No comments:

Post a Comment