|
SQL 中自己创建函数,分割字符串(6) end GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO
-- getstrofindex 输入一个未分割的字符串,舒服分割符号,舒服要取得的字符位置 -- 返回 制定位置的字符串 CREATE function getstrofindex (@str varchar(8000),@splitstr varchar(4),@index int=0) returns varchar(8000) as begin declare @str_return varchar(8000) declare @start int declare @next int declare @location int
select @start =1 select @next = 1 --如果习惯从0开始则select @next =0 select @location = charindex(@splitstr,@str,@start) while (@location <>0 and @index > @next ) begin
|