从第一个汉字开始分割字符串

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              中国

*/

 
 
原文地址:https://www.cnblogs.com/accumulater/p/6244601.html