select col from [dbo].[GetInPara]('101,102,103',',')

SQL 以逗号分隔查询;调用自定义函数

 

 

USE [xxx]
GO
/****** Object:  UserDefinedFunction [dbo].[GetInPara]    Script Date: 2019/9/26 11:06:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER   function   [dbo].[GetInPara](@c varchar(2000),@split varchar(2))   
returns  @t   table(col   varchar(20))   
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
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2021-05-25
猜你喜欢
  • 2022-12-23
  • 2021-05-25
  • 2021-08-30
  • 2021-12-11
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案