在MS SQL Server 2017有了一个新函数TRIM,整合以前版本LTRIM和RTRIM. 这几个函数都是去除字符串头部后尾部的空格. DECLARE @str NVARCHAR(MAX) = N' Insus.NET ' SELECT @str AS [str], [dbo].[svf_StringLength](@str) AS [length] SELECT LTRIM(@str) AS [str], [dbo].[svf_StringLength](LTRIM(@str)) AS…
sql中用LTRIM ( ),RTRIM ( ).分别截断首尾空格,返回字符表达式. 例1: DECLARE @string_to_trim varchar(60)SET @string_to_trim = ' Four spaces are after the period in this sentence. 'SELECT 'BEGIN|' + CHAR(13) + ltrim(rtrim(@string_to_trim))+'|END' 詳見:http://blog.sina.…