Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day all I have select query with a where and a and condition with a case statement I cannot get the case statement to work correctly please help me

SQL
AND Sa.AllocatedDate =
            CASE WHEN @Allocated='not Allocated' THEN NULL
            CASE WHEN @Allocated='Allocated' THEN IS NOT null
            END
Posted

Remove IS from query.
 
Share this answer
 
Comments
mrDivan 22-Aug-13 4:56am    
Thanks but it is not working
thatraja 22-Aug-13 5:14am    
'not working' mean what? what's the error message? I think you have assign a dummy date( like 1900-01-01) instead of NOT NULL
thatraja 22-Aug-13 5:13am    
'not working' mean what? what's the error message? I think you have assign a dummy date( like 1900-01-01) instead of NOT NULL
 
Share this answer
 
try this...
SQL
AND ISNULL(DATALENGTH(Sa.AllocatedDate),0) =
            CASE WHEN @Allocated='not Allocated' THEN 0
            ELSE 8 END

Happy Coding!
:)
 
Share this answer
 
Thanks I solved it my self
VB
AND

        ((@Allocated='not Allocated' and Sa.AllocatedDate IS NULL)
        OR
        (@Allocated='Allocated' and Sa.AllocatedDate IS NOT NULL))
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900