Remove leading and trailing spaces from a string:
SELECT TRIM(' SQL Tutorial! ') AS TrimmedString;
Try it Yourself »
The TRIM() function removes the space character OR other specified characters from the start or end of a string.
By default, the TRIM() function removes leading and trailing spaces from a string.
Note: Also look at the LTRIM() and RTRIM() functions.
TRIM([
characters FROM
]
string)
Parameter | Description |
---|---|
characters FROM | Optional. Specific characters to remove |
string | Required. The string to remove spaces or characters from |
Works in: | SQL Server (starting with 2017), Azure SQL Database, |
---|
Remove characters and spaces from a string:
SELECT TRIM('#! ' FROM ' #SQL Tutorial! ') AS TrimmedString;
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!