Microsoft SQL Server String Functions Left

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Returns a sub string starting with the left most char of a string and up to the maximum length specified.

Parameters:

  1. character expression. The character expression can be of any data type that can be implicitly converted to varchar or nvarchar, except for text or ntext
  2. max length. An integer number between 0 and bigint max value (9,223,372,036,854,775,807).
    If the max length parameter is negative, an error will be raised.
SELECT LEFT('This is my string', 4) -- result: 'This'

If the max length is more then the number of characters in the string, the entier string is returned.

SELECT LEFT('This is my string', 50) -- result: 'This is my string'


Got any Microsoft SQL Server Question?