String Functions



String Functions in SQL Server


String functions in SQL server are scalar functions that perform an operation on a string input value and return a string or numeric value.


All the functions are listed with description as follows:


FunctionDescription
ASCIIReturns the ASCII code value of the leftmost character of a character expression.
Syntax:

ASCII ( character_expression )
FunctionDescription
CHARConverts an int ASCII code to a character.
Syntax:

CHAR ( integer_expression )
FunctionDescription
CHARINDEXReturns the starting position of the specified expression in a character string.
Syntax:

CHARINDEX ( expression1 ,expression2 [ , start_location ] )
FunctionDescription
DIFFERENCEReturns an integer value that indicates the difference between the SOUNDEX values of two character expressions.
Syntax:

DIFFERENCE ( character_expression , character_expression )
FunctionDescription
LEFTReturns the left part of a character string with the specified number of characters.
Syntax:

LEFT ( character_expression , integer_expression )
FunctionDescription
LENReturns the number of characters, instead of the number of bytes, of the specified string expression, excluding trailing blanks.
Syntax:

LEN ( string_expression )
FunctionDescription
LOWERReturns a character expression after converting uppercase character data to lowercase.
Syntax:

LOWER ( string_expression )
FunctionDescription
LTRIMReturns a character expression after it removes leading blanks.
Syntax:

LTRIM ( string_expression )
FunctionDescription
NCHARReturns the Unicode character with the specified integer code, as defined by the Unicode standard.
Syntax:

NCHAR ( integer_expression )
FunctionDescription
PATINDEXReturns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types.
Syntax:

PATINDEX ( '%pattern%' , expression )
FunctionDescription
QUOTENAMEReturns a Unicode string with the delimiters added to make the input string a valid Microsoft SQL Server 2005 delimited identifier.
Syntax:

QUOTENAME ( 'character_string' [ , 'quote_character' ] )
FunctionDescription
REPLACEReplaces all occurrences of the second specified string expression in the first string expression with a third expression.
Syntax:

REPLACE ( 'string_expression1' , 'string_expression2' , 'string_expression3' )
FunctionDescription
REPLICATERepeats a character expression for a specified number of times.
Syntax:

REPLICATE ( character_expression ,integer_expression ) 
FunctionDescription
REVERSEReturns the reverse of a character expression.
Syntax:

REVERSE ( character_expression )
FunctionDescription
RIGHTReturns the right part of a character string with the specified number of characters
Syntax:

RIGHT ( character_expression , integer_expression )
FunctionDescription
RTRIMReturns a character string after truncating all trailing blanks.
Syntax:

RTRIM ( character_expression )
FunctionDescription
SOUNDEXReturns a four-character (SOUNDEX) code to evaluate the similarity of two strings.
Syntax:

SOUNDEX ( character_expression )
FunctionDescription
SPACEReturns a string of repeated spaces
Syntax:

SPACE ( integer_expression )
FunctionDescription
STRReturns character data converted from numeric data.
Syntax:

STR ( float_expression [ , length [ ,  ] ] )
FunctionDescription
STUFFDeletes a specified length of characters and inserts another set of characters at a specified starting point.
Syntax:

STUFF ( character_expression , start , length ,character_expression )
FunctionDescription
SUBSTRINGReturns part of a character, binary, text, or image expression.
Syntax:

SUBSTRING ( expression ,start , length )
FunctionDescription
UNICODEReturns the integer value, as defined by the Unicode standard, for the first character of the input expression.
Syntax:

UNICODE ( 'ncharacter_expression' )
FunctionDescription
UPPERReturns a character expression with lowercase character data converted to uppercase
Syntax:

UPPER ( character_expression )

Connection String

SQL Server Connection String Formats

posted on 2019-08-27 05:53:53 - SQL Server Tutorials


UNION

union in SQL server

posted on 2019-08-09 23:05:33 - SQL Server Tutorials


System Functions

System Functions in SQL Server

posted on 2019-08-09 06:14:33 - SQL Server Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials