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,942 of 19,505    |
|    M Joomun to Erland Sommarskog    |
|    Re: Correct syntax please    |
|    18 Oct 10 09:32:39    |
      From: m.a.joomun@qmul.ac.uk              On 14/10/2010 16:07, Erland Sommarskog wrote:       > 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.       >              Thanks for your response. The syntax you gave was what I was trying       originally and there's no difference in the results returned; correct       results if 'DateAssayReq' is used as search criteria, no results       returned if labno is used, either on it's own or in conjunction with       'DateAssayReq'.              Any other ideas?              --- 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