Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,932 of 19,505    |
|    Erland Sommarskog to M Joomun    |
|    Re: Correct syntax please    |
|    14 Oct 10 15:07:11    |
      From: esquel@sommarskog.se              M Joomun (m.a.joomun@qmul.ac.uk) writes:       > I've got a search form where users can search for records from the db.       > The App calls a stored procedure which executes the sql below. The form       > has two search criteria users have requested, 'labno' and 'DateAssayReq'.       >       > The App works well for the date criteria and will find the correct       > record(s), but will not return any records whatever I enter for the       > labno, even though I know the labno exists in the db.       >       > Can someone see what I've done wrong?              The part with datalength looks funky. "DataLength(@DateAssayReq)" will       never be 0. It will be 3 or NULL.              Use:               WHERE (@labno IS NULL OR LabNo = @labno)        AND (@DateAssayReq IS NULL OR DateAssayReq = @DateAssayReq)                     Also make sure that you pass NULL for search conditions that do not apply.              --       Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se              Books Online for SQL Server 2005 at       http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx       Books Online for SQL Server 2000 at       http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca