title: Operator BETWEEN in SQL Server
body: <p>I was writing sub query in stored procedure to get the values between Orders stored as varchar datatype. When i run the query it shows:</p>
  
  <blockquote>
    <p>Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression.</p>
  </blockquote>
  
  <p>I googled a bit and found the problem because of returning more than 1 value in a sub query. </p>
  
  <p>But in my case i need all the values which lies between the given input. Can anybody tell me what way i can achieve this ..</p>
  
  <p>Code:</p>
  
  <pre><code>SELECT ROW_NUMBER()OVER(
                          ORDER BY po.id) AS SNo ,
         pd.Copies AS Quantity,
         pd.EstUnitPrice AS UniPrice,
         pd.Copies*pd.EstUnitPrice AS Total,
  
    (SELECT value
     FROM BibContents
     WHERE bibid=pd.BibId
       AND sfld='a'
       AND tagno='245') AS Title,
  
    (SELECT value
     FROM BibContents
     WHERE bibid=pd.BibId
       AND sfld='a'
       AND tagno='020') AS 'ISSN/ISBN',
  
    (SELECT value
     FROM BibContents
     WHERE bibid=pd.BibId
       AND sfld='a'
       AND tagno='100')AS Author
  FROM  [VibrantMas].[dbo].[PoDetails] AS pd
        INNER JOIN Porders AS po ON po.Id=pd.PoId
  WHERE po.No BETWEEN '000021' AND '000024'
  </code></pre>