Monday, July 9, 2012

String Functions in T-SQL:


1) ASCII (char_expression..) : Returns the ASCII value of the character. See the below example

      
2 ) CHAR(int_expression): Returns the charater of the integer parameter (ASCII value). See the below example

3) CHARINDEX (exp_To_Find, exp_To_Search, start_location_search): Returns the position of the serach value in a givn string.

4) CONCAT(string_value1, string_value2.....string_valueN): Concats all the string specified as parameters




SELECT CONCAT
('Hello','World')

5) LEFT(string_exp, n) : Returns the string with specifed length







SELECT


LEFT('Hello World SQL',10)

6) LEN (string_exp): Returns the length of the string




USE


AdventureWorks;
GO


SELECT


LEN(FirstName) AS Length, FirstName, LastName
FROM


Sales.vIndividualCustomer
WHERE


CountryRegionName = 'Australia';
GO




       


No comments:

Post a Comment