日期:2014-05-17 浏览次数:20551 次
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[SendChitOfHead]
@CsendmemberId int,
@CfrommemberIds varchar(8000),---
@CpersonIds varchar(8000),---
@CpersonType varchar(500),
@Ctitle varchar(500),
@CContent text,
@Ctype varchar(500),
@CoperateIP varchar(500),
@Cstate varchar(500),
@CSid int,
@CCids varchar(8000) ,---
@CphoneNums varchar(8000)---
as
begin
declare @CfrommemberId varchar(8000)
declare @CpersonId varchar(8000)
declare @CCid varchar(8000)
declare @CphoneNum varchar(8000)
set @CfrommemberIds=@CfrommemberIds+','
set @CpersonIds=@CpersonIds+','
set @CCids=@CCids+','
set @CphoneNums=@CphoneNums+','
while(@CfrommemberIds<>'')
begin
set @CfrommemberId=convert(VARCHAR,left(@CfrommemberIds,Charindex(',',@CfrommemberIds,1)-1))
set @CpersonId=convert(VARCHAR,left(@CpersonIds,Charindex(',',@CpersonIds,1)-1))
set @CCid=convert(VARCHAR,left(@CCids,Charindex(',',@CCids,1)-1))
set @CphoneNum=convert(VARCHAR,left(@CphoneNums,Charindex(',',@CphoneNums,1)-1))
-----print @id
insert into Sys_chit(CsendmemberId,CfrommemberId,CpersonId,CpersonType,Ctitle,CContent,Ctype,CoperateIP,Csendtime,Cstate,CSid,CCid,CsendState,CphoneNum,COperator) values(@CsendmemberId,@CfrommemberId,@CpersonId,@CpersonType,@Ctitle,@CContent,@Ctype,@CoperateIP,getdate(),@Cstate,@CSid,@CCid,' ',@CphoneNum,' ')
set @CfrommemberIds=stuff(@CfrommemberIds,1,charindex(',',@CfrommemberIds,1),'')
set @CpersonIds=stuff(@CpersonIds,1,charindex(',',@CpersonIds,1),'')
set @CCids=stuff(@CCids,1,charindex(',',@CCids,1),'')
set @CphoneNums=stuff(@CphoneNums,1,charindex(',',@CphoneNums,1),'')
end
end
DROP TABLE test
CREATE TABLE test (NAME VARCHAR(max))
INSERT INTO test VALUES('15874,154874,15474,15474,1547,154748,1584847')
go
select
SUBSTRING(a.NAME,number,CHARINDEX(',',a.NAME+',',number)-number) as spnum,'内容' ct
from
test a,master..spt_values
where
number >=1 and number<=len(a.NAME)
and type='p'
and substring(','+a.NAME,number,1)=','
/*
spnum &nb