How to use result of an SQL select statement in dbo.fnSplit function as input

后端 未结 1 1108
北恋
北恋 2021-01-16 06:42

I have a requirement to use a comma seperated string (which is a value in a table column) in \'IN\' clause of an SQL statement(SQL server 2008) For this I am using below sp

相关标签:
1条回答
  • 2021-01-16 07:36

    Why not try it this way

    declare @Prefix2Include as Varchar(500)
    
    SELECT  @Prefix2Include = Prefix2Include FROM dbo.vw_PrefixToInclude
    
    select * from dbo.fnSplit(@Prefix2Include , ',')
    

    Update

    Select * From @t v 
    Where v.EmpPrefix IN 
    (select * from dbo.fnSplit(@Prefix2Include, ','))
    
    0 讨论(0)
提交回复
热议问题