公司网站实名认证怎么做,陕西企业营销型网站,企业网站搭建程序,好玩的游戏自定义取出第几个分割字符前的字符串#xff0c;默认位置#xff08;0#xff09;格式#xff1a;dbo.split(字段名,分隔字符,取出的第几个字符串)如果没有分隔的字符#xff0c;则返回整个字符串。如果取出的位置字符串的位置超出Index则返回空。CREATE FUNCTION [dbo].[…自定义取出第几个分割字符前的字符串默认位置0格式dbo.split(字段名,分隔字符,取出的第几个字符串)如果没有分隔的字符则返回整个字符串。如果取出的位置字符串的位置超出Index则返回空。CREATE FUNCTION [dbo].[split] (str nvarchar(4000),code varchar(10),no int ) RETURNS varchar(200)AS BEGIN declare intLen intdeclare count intdeclare indexb intdeclare indexe intset intLenlen(code)set count0set indexb1if no0 if charindex(code,str,indexb)0 return left(str,charindex(code,str,indexb)-1) else return strwhile charindex(code,str,indexb)0 begin set countcount1 if countno break set indexbintLencharindex(code,str,indexb) end if countno begin set indexeintLencharindex(code,str,indexb) if charindex(code,str,indexe)0 return substring(str,charindex(code,str,indexb)len(code),charindex(code,str,indexe)-charindex(code,str,indexb)-len(code)) else return right(str,len(str)-charindex(code,str,indexb)-len(code)1) endreturn END 转载于:https://www.cnblogs.com/hanguoji/archive/2005/12/02/289322.html