[MSSQL] 문자열 분할 계산

771 단어 Datefunction
-- =============================================   
-- Author: <David Gong>   
-- Create date: <2011-12-06>   
-- Description: <        >   
-- ============================================= 
ALTER FUNCTION [dbo].[func_get_split_num](@str varchar(8000))
returns int
as
begin
declare @int_return int
declare @start int
declare @next int
declare @location int
select @str=','+@str+','
select @str=replace(@str,',,',',')
select @start=1
select @next=1
select @location=charindex(',',@str,@start)
while(@location<>0)
begin
select @start=@location+1
select @location=charindex(',',@str,@start)
select @next=@next+1
end
select @int_return=@next-2
return @int_return
end

좋은 웹페이지 즐겨찾기