go --创建函数 create function [dbo].[m_splitNchinese] ( @str_one nvarchar(100) ) returns @result table (colone nvarchar(20),coltwo nvarchar(20)) as begin insert @result select left(@str_one,patindex('%[^_@0-9a-z]%',@str_one)-1) , right(@str_one,len(@str_one)-patindex('%[^_@0-9a-z]%',@str_one)+1) return end --测试示例 select * from [dbo].[m_splitNchinese] ('Chinese中国') --运行结果 /* colone coltwo -------------------- -------------------- Chinese 中国 */
[MSSQL]从第一个汉字开始分割字符串
关注
打赏