SQL Server RIGHT() 函数
定义和用法
RIGHT() 函数从字符串中提取一定数量的字符(从右边开始)。
实例
例子 1
从字符串中提取 3 个字符(从右边开始):
SELECT RIGHT('SQL Tutorial', 3) AS ExtractString;
例子 2
从 "CustomerName" 列中的文本提取 5 个字符(从右边开始):
SELECT RIGHT(CustomerName, 5) AS ExtractString FROM Customers;
例子 3
从字符串中提取 100 个字符(从右边开始):
SELECT RIGHT('SQL Tutorial', 100) AS ExtractString;
语法
RIGHT(string, number_of_chars)
参数
| 参数 | 描述 |
|---|---|
| string | 必需。要提取的字符串。 |
| number_of_chars |
必需。要提取的字符数。 如果 number_of_chars > 字符串长度,它将返回整个字符串。 |
技术细节
| 适用于: |
|
|---|