create function dbo.fn_pmt_pis_splitstr(@sourcesql varchar(8000),@strseprate varchar(10))
returns @temp table(customer int)
as
begin
declare @i int
set @sourcesql=rtrim(ltrim(@sourcesql))
set @i=charindex(@strseprate,@sourcesql)
while @i>=1
begin
insert @temp values(left(@sourcesql,@i-1))
set @sourcesql=substring(@sourcesql,@i+1,len(@sourcesql)-@i)
set @i=charindex(@strseprate,@sourcesql)
end
if @sourcesql<>''
insert @temp values(@sourcesql)
return
end
SQL分割字串
t sql對字串的處理能力比較弱,比如我要迴圈遍歷象1,2,3,4,5這樣的字串,如果用陣列的話,遍歷很簡單,但是t sql不支援陣列,所以處理下來比較麻煩。下邊的函式,實現了象陣列一樣去處理字串。一,用臨時表作為陣列 create function f split c varchar 2000 s...
SQL分割字串
if object id dbo.fn split isnot null drop function dbo.fn split gocreate function dbo.fn split inputstr varchar 8000 seprator varchar 10 returns temp ...
SQL 字串分割函式
create function dbo f split sourcesql varchar 8000 strseprate varchar 10 returns temp table a varchar 100 as begin declare iint set sourcesql rtrim lt...