--将行转为字符串
select stuff((select top 20 ','+ QQ from dl_QQ where uiid=1 order by tim desc for xml path('')),1,1,'')




-- =============================================
 
-- Description:	将字符串转为表格
/*
	例:select * from [f_split]('spu0987*5//spu0988*5/spu0989*5', '/')
	--将表格转为字符串
	DECLARE @S nVARCHAR(max)
SELECT @S=ISNULL(@S+',','')+[col] FROM [f_split]('spu0987*5//spu0988*5/spu0989*5', '/')
PRINT @S
*/
-- =============================================
create function [dbo].[strToTab](@c varchar(max),@split varchar(2))  
returns @t table(col nvarchar(255))  
as  
    begin  
   
      while(charindex(@split,@c)<>0)  
        begin  
          insert   @t(col)   values   (substring(@c,1,charindex(@split,@c)-1))  
          set   @c   =   stuff(@c,1,charindex(@split,@c),'')  
        end  
      insert   @t(col)   values   (@c)  
      return  
    end

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-02-08
  • 2021-10-14
  • 2022-12-23
  • 2022-02-02
猜你喜欢
  • 2021-12-06
  • 2021-12-18
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-12-25
  • 2022-02-08
相关资源
相似解决方案