Monday, November 26, 2007

String Functions

Function

Oracle

Microsoft SQL Server

String concatenate

||, CONCAT

+ (expression1 + expression2)

Convert character to ASCII

ASCII

ASCII

Convert ASCII to character

CHR

CHR

Return starting point of character in character string (from left)

INSTR (with two arguments)

CHARINDEX

Length of character string

LENGTH

DATALENGTH or LEN

Convert characters to uppercase

UPPER

UPPER

Convert characters to lowercase

LOWER

LOWER

Remove leading blank spaces

LTRIM

LTRIM

Remove trailing blank spaces

RTRIM

RTRIM

Substring

SUBSTR (second argument cannot be a negative number)

SUBSTRING

Pad left side of character string

LPAD

N/A

Starting point of pattern in character string

INSTR

PATINDEX

Repeat character string multiple times

RPAD

REPLICATE

Phonetic representation of character string

SOUNDEX

SOUNDEX

String of repeated spaces

RPAD

SPACE

Character data converted from numeric data

TO_CHAR

STR

Replace characters

REPLACE

STUFF

Capitalize first letter of each word in string

INITCAP

N/A

Translate character string

TRANSLATE

N/A

Greatest character string in list

GREATEST

N/A

Least character string in list

LEAST

N/A

Convert string if NULL

NVL

ISNULL

No comments: