Select IN on more than 2100 values

后端 未结 1 1423
鱼传尺愫
鱼传尺愫 2020-12-07 05:05

How can you do a select in on more than 2100 values?


  SELECT    sub_acct_no,  ...
  FROM  dbo.Closed_ORDER
  WHERE o         


        
1条回答
  •  长情又很酷
    2020-12-07 05:41

    First load the values into XML

    
    
        
    
    
    

    Then use the xml in the sql query

    
    DECLARE @xmlOrd_no       xml = 
    
    
    DECLARE @tblOrd_no          TABLE (ID varchar(20))
    
    
    INSERT INTO @tblOrd_no
    SELECT tbl.Col.value('.', 'varchar(20)')
    FROM    @xmlOrd_no.nodes('/ul/li') tbl(Col)
    
    
    SELECT  sub_acct_no,  ...
    FROM    dbo.Closed_ORDER
    WHERE   ord_no IN (SELECT ID FROM @tblOrd_no)
    
    

    You can also do a dump of the XML and it is properly formatted in HTML

     #strResult#
    

    0 讨论(0)
提交回复
热议问题