LEFT function in SQL Server
The article will learn and show you how to use the LEFT function in SQL Server to extract some characters from the left side of a given string.
Describe
The LEFT function in SQL Server allows you to extract a substring from a large string, starting from the leftmost character.
Syntax
To use LEFT function in SQL Server, we use the following syntax:
LEFT(chuoi, so_ky_tu)
Parameters :
- chuoi: can be a string, variable or column that you want to extract.
- so_ky_tu: a positive integer that specifies the number of characters that will be returned from the cycle, starting from the leftmost character.
Note :
- If so_ky_tu exceeds the length of the string, LEFT function returns the original string.
- The LEFT function can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.
For example
Take a look and explore some examples of LEFT functions in SQL Server.
SELECT LEFT('TipsMake.com', 12);
Result: 'Quantrimang.'
SELECT LEFT('TipsMake.com', 4);
Result: 'Quan'
SELECT LEFT('Quan Tri Mang', 9);
Result: 'Quan Tri '
SELECT LEFT('Quan Tri Mang', 100);
Result: 'Quan Tri Mang '
Previous article: DATALENGTH function in SQL Server
Next article: LEN function in SQL Server
4.3 ★ | 3 Vote
You should read it
- LEFT and LEFTB functions - Functions for cutting strings in Excel
- T.DIST - The function returns the Student t-distribution on the left in Excel
- How to switch left to right mouse on Windows 11
- LEFT JOIN in SQL
- Do you know the structure and usage of the LEFT function in Excel?
- How to combine Vlookup function with Left function
- How to fix the problem of left clicking on Windows
- Why are some people left-handed while most of us are right-handed?
May be interested
- DATEPART function in SQL Serverthe datepart function in sql server returns a time value of the input argument, which can be day, month, year, quarter, hour, minute, second, millisecond ... the return value is an integer type (int)
- How to combine Vlookup function with Left functionwhen combining the vlookup function with the left function, we will easily separate the values to find the right information we need.
- DATENAME function in SQL Serverthe datename function in sql server returns a time value of the input argument, which can be day, month, year, quarter, hour, minute, second, millisecond ... the return value is a string type (ascii)
- Do you know the structure and usage of the LEFT function in Excel?this article guides you in detail about the structure and usage of common and effective left function in excel
- ROUND function in SQL Serverthe article will give you detailed instructions on how to use the sql server round () function with the syntax and specific examples to make it easier to visualize and capture the function better.
- CEILING function in SQL Serverthe ceiling function in sql server returns the smallest integer value greater than or equal to the transmitted numeric expression.
- RIGHT function in SQL Serverthe article will explore and guide you how to use the right function in sql server to extract some characters from the right side of a given string.
- FLOOR function in SQL Serverthe floor function in sql server returns the largest integer value but less than or equal to the transmitted numeric expression.
- MONTH function in SQL Serverthis article will show you in detail how to use the datetime month () processing function in sql server with specific syntax and examples to better visualize and capture functions.
- DATEDIFF function in SQL Serverthis article will show you in detail how to use sql server's datetime datediff () function with syntax and specific examples to make it easier to visualize and capture functions.