0% found this document useful (0 votes)
5 views2 pages

String Functions

The document provides a list of string functions available in SQL Server, detailing their purpose and usage. Functions include LEFT, RIGHT, LEN, LOWER, UPPER, CHAR, ASCII, NCHAR, Unicode, and others, each with examples and expected outputs. The document serves as a reference for performing various string manipulations in SQL queries.

Uploaded by

drsdcsds2024
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

String Functions

The document provides a list of string functions available in SQL Server, detailing their purpose and usage. Functions include LEFT, RIGHT, LEN, LOWER, UPPER, CHAR, ASCII, NCHAR, Unicode, and others, each with examples and expected outputs. The document serves as a reference for performing various string manipulations in SQL queries.

Uploaded by

drsdcsds2024
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

String Functions:

8. LEFT(string, number)

Extract Number of Character from a


left side of a string
This are used to perform different operation on
string Left(‘Sherya’,2)

1. LEN Output  Sh (Indexing starting from 1)


Returns number of character
LEN(‘Amit’)
Output – 4 9. RIGHT(string, number)

2. LOWER Extract Number of Character from a


Converts Character to lower case RIGHT side of a string
Lower(‘Amit)
Left(‘Sherya’,2)
Output – amit
Output  ya (Indexing starting from 1)
3. UPPER
Converts Character to lower case
UPPER(‘Amit)
10. LTRIM
Output – AMIT
Removes blank spaces from the left
side
LTRIM (………. OOP)
In SQL Server Management Studio (SSMS), ASCII code is Output  OOP
used to work with character data. The ASCII() function in SQL
Server allows you to get the ASCII value of the first character
11. RTRIM
in a string.
Removes blank spaces from the right
side
RTRIM(OOP………..)
4. CHAR Output  OOP
Returns character of a given ASCII code
Ex: CHAR(65)
Output -> A 12. LTRIM (RTRIM (‘……. Orange…….))
Removes blank spaces from both sides
5. ASCII Output Orange
Returns ASCII code of a given character
13. Reverse
SELECT ASCII('A') AS ASCII Value; --
Reverse the string
Returns 65
Reverse(‘Sumit’)
Output timuS
6. NCHAR(255)
Returns y
The NCHAR() function in SQL Server is used
to return the Unicode character
corresponding to a specified integer
code point.

7. Unicode 14. Replace(String 1, String 2, String 3)


String 1  Given String
Unicode is a universal character encoding
String 2  Search String
standard that provides a unique code for every
String 3  Replace String
character, symbol, and script across different
It will search for string 2 in string 1
languages and platforms
and replaces with string 3
Unicode(‘Amara’) Replace(‘Computer’,’ut’,’ir’)
Output Compirer
Output: 65
15. Substring(String, Starting Position,
Number of Char to be print)

It extract required string from a given


string based on starting position and
number of character

Substring(‘Computer’,4,3)

Output put

16. Stuff(String 1, Starting number position,


Number of character to be print from,
String 2)
--HOW TO SELECT STUFF('Hello World', 7,
5, 'SQL')

Output  Hello SQL

17. Replicate(string, Number)


(‘Amara’,2)
Ouput  Amara Amara

18. Charindex  It gives position of a given


character
String 1  Specified Character
String 2  Given Character

Ex. Charindex(String1, String2)


Charindex(‘s’,Ramesh)
Output  5

You might also like