create proc test
@SiftValue varchar(max)='Dim1:1,2%Dim2:3,4%Dim3:5,6'
as
set @SiftValue = REPLACE(@SiftValue,'Dim1:','')
set @SiftValue = REPLACE(@SiftValue,'Dim2:','')
set @SiftValue = REPLACE(@SiftValue,'Dim3:','')
declare @PersonCondition varchar(max) -----人维度
declare @MissionCondition varchar(max)-----任务维度
declare @TimeCondition varchar(max) -----时间维度
if @SiftValue <> ''
Begin
if CHARINDEX('%',@SiftValue,1)>0
Begin
set @PersonCondition= SUBSTRING(@SiftValue,1,CHARINDEX('%',@SiftValue,1)-1)
set @SiftValue= SUBSTRING(@SiftValue,CHARINDEX('%',@SiftValue,1)+1,LEN(@SiftValue)-CHARINDEX('%',@SiftValue,1))
set @MissionCondition =SUBSTRING(@SiftValue,1,CHARINDEX('%',@SiftValue,1)-1)
set @SiftValue= SUBSTRING(@SiftValue,CHARINDEX('%',@SiftValue,1)+1,LEN(@SiftValue)-CHARINDEX('%',@SiftValue,1))
set @TimeCondition=@SiftValue
print @PersonCondition
print @MissionCondition
print @TimeCondition
End
End
exec test