xiaojian1

 

//调用fn_split1

select Id,Title
 from ListTransField where Id in(
select value from [fn_Split1]((select TransField_Id from ListCompany where Company=\'客户公司\'),\',\')
)


create FUNCTION [dbo].[fn_Split1](      
 @String nvarchar (max),      
 @Delimiter nvarchar (10)      
)      
RETURNS @ValueTable TABLE ([Value] NVARCHAR(max),[id] int)      
BEGIN      
 DECLARE @NextString nvarchar(max),      
  @Pos int,      
  @NextPos int,      
  @CommaCheck nvarchar(1),    
 @id int    
    
set @id=1      
       
 SET @NextString = \'\'      
 SET @CommaCheck = right(@String,1)       
       
 SET  @String = @String + @Delimiter      
       
  SET @Pos = CHARINDEX(@Delimiter,@String)      
  SET @NextPos = 1      
       
 WHILE (@pos <>  0)        
 BEGIN      
  SET @NextString = SUBSTRING(@String,1,@Pos - 1)      
        
  INSERT INTO @ValueTable ( [Value],[id]) VALUES (@NextString,@id)      
        
  SET @String = SUBSTRING(@String,@pos +1,LEN(@String))      
         
  SET @NextPos = @Pos      
  SET @pos  = CHARINDEX(@Delimiter,@String)      
    
 set @id = @id +1    
 END      
       
 RETURN      
END  
 
GO  

分类:

技术点:

相关文章:

  • 2021-11-01
  • 2021-11-17
  • 2021-11-17
  • 2021-11-01
  • 2021-08-07
  • 2021-07-12
  • 2021-04-22
  • 2021-12-27
猜你喜欢
  • 2018-05-28
  • 2021-08-04
  • 2021-11-06
  • 2021-11-19
  • 2021-11-19
  • 2021-09-07
  • 2022-01-01
相关资源
相似解决方案