Skip to main content

Posts

Showing posts with the label SQL Buil-In Functions

SQL Built-In Functions, String Functions,SOUNDEX

Returns a four-character (SOUNDEX) code to evaluate the similarity of two strings. Syntax SOUNDEX ( character_expression ) Arguments character_expression Is an alphanumeric expression of character data. character_expression can be a constant, variable, or column. Return Types varchar  **  SOUNDEX converts an alphanumeric string to a four-character code to find similar-sounding words or names. The first character of the code is the first character of character_expression and the second through fourth characters of the code are numbers. Vowels in character_expression are ignored unless they are the first letter of the string. String functions can be nested **   Examples The following example shows the SOUNDEX function and the related DIFFERENCE function. In the first example, the standard SOUNDEX values are returned for all consonants. Returning the SOUNDEX for Smith and Smythe returns the same SOUNDEX result because...

SQL Buil-In Functions, String Functions,NCHAR

Returns the Unicode character with the specified integer code, as defined by the Unicode standard Syntax NCHAR ( integer_expression )   Arguments integer_expression Is a positive whole number from 0 through 65535. If a value outside this range is specified, NULL is returned.   Return Types nchar Examples A. Using NCHAR and UNICODE The following example uses the UNICODE and NCHAR functions to print the UNICODE value and the NCHAR (Unicode character) of the second character of the København character string, and to print the actual second character, ø .  DECLARE @nstring nchar(8) SET @nstring = N'København' SELECT UNICODE(SUBSTRING(@nstring, 2, 1)),    NCHAR(UNICODE(SUBSTRING(@nstring, 2, 1))) GO Here is the result set.  ----------- - 248         ø(1 row(s) affected) B. Using SUBSTRING, UNICODE, CONVERT, and NCHAR   The following example uses the ...

SQL Buil-In Functions, String Functions,ASCII

Returns the ASCII code value of the leftmost character of a character expression. Transact-SQL Syntax Conventions Syntax ASCII ( character_expression ) Arguments character_expression Is an expression of the type char or varchar . Return Types int  Examples  SET TEXTSIZE 0 SET NOCOUNT ON -- Create the variables for the current character string position -- and for the character string. DECLARE @position int, @string char(15) -- Initialize the variables. SET @position = 1 SET @string = 'Du monde entier' WHILE @position <= DATALENGTH(@string)    BEGIN    SELECT ASCII(SUBSTRING(@string, @position, 1)),       CHAR(ASCII(SUBSTRING(@string, @position, 1)))     SET @position = @position + 1    END SET NOCOUNT OFF GO Here is the result set. ----------- - 68          D          ...