set ansi_nulls on
set quoted_identifier on
goalter function [dbo].[f_split](@sourcesql varchar(8000),@strseprate varchar(10))
returns @temp table(a varchar(100))
--實現split功能 的函式
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)
endif @sourcesql<>'/'
insert @temp values(@sourcesql)
return
end使用:
create proc p_modrelateuserfun
@userid int ,
@funids varchar(2000)
asdelete from dbo.relateuserfun where userid=@userid
if(@funids<>'' or @funids is not null)
insert into [customer].[dbo].[relateuserfun]
([funid],[userid])
select a ,@userid from customer.dbo.f_split(@funids,',')
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...
SQL 字串分割函式
create function dbo split input varchar max split varchar max returns table table col varchar max as begin while charindex split,input 0 begin insert ...
分割字串的sql函式
create function stringtotable stringx varchar 8000 split nvarchar 10 returns tableresult table tableid nvarchar 100 as begin declare index int declare...