截取两个字符之间的函数?
求截取两个字符之间的函数,
比如
【海鲜】。【水晶】
得到 海鲜,水晶
------解决思路---------------------- 这样?你那句号变逗号是嘛意思?
--创建函数(得到字符串中的汉字) create function [dbo].[m_getchinese] ( @chinese nvarchar(max) ) returns varchar(100) as begin while patindex('%[^吖-咗]%',@chinese) > 0 begin set @chinese = stuff(@chinese,patindex('%[^吖-咗]%',@chinese),1,N''); end return @chinese end GO DECLARE @a VARCHAR(50) SET @a='【海鲜】。【水晶】' select dbo.[m_getchinese](@a) /* ---------------------------------------------------------------------------------------------------- 海鲜水晶 */------解决思路---------------------- 引用: 这样?你那句号变逗号是嘛意思? --创建函数(得到字符串中的汉字) create function [dbo].[m_getchinese] ( @chinese nvarchar(max) ) returns varchar(100) as begin while patindex('%[^吖-咗]%',@chinese) > 0 begin set @chinese = stuff(@chinese,patindex('%[^吖-咗]%',@chinese),1,N''); end return @chinese end GO DECLARE @a VARCHAR(50) SET @a='【海鲜】。【水晶】' select dbo.[m_getchinese](@a) /* ---------------------------------------------------------------------------------------------------- 海鲜水晶 */ %[^吖-咗]% 这是啥东西。为啥有这个就能读取到了。把2个汉字给删了就没了。
------解决思路---------------------- 引用: 这样?你那句号变逗号是嘛意思? --创建函数(得到字符串中的汉字) create function [dbo].[m_getchinese] ( @chinese nvarchar(max) ) returns varchar(100) as begin while patindex('%[^吖-咗]%',@chinese) > 0 begin set @chinese = stuff(@chinese,patindex('%[^吖-咗]%',@chinese),1,N''); end return @chinese end GO DECLARE @a VARCHAR(50) SET @a='【海鲜】。【水晶】' select dbo.[m_getchinese](@a) /* ---------------------------------------------------------------------------------------------------- 海鲜水晶 */ 你这个的代码逻辑是把非汉字的字符去掉是吧