SQL Server 2008 condition in case

Tags:
SQL Server 2008
Hi, I have a condition (with a parameter named @Par1=IS NOT NULL) in query like this select * from table1 where Numeric field1 IS NOT NULL. It runs okay but where numeric field1 =@Par1 it, it doesn't work. Another example:
@A= '>0' and @invcode = 1
@InvCode INT,
@A nvarchar(20)
 
SELECT     GoodCode, Stock
FROM         Good
WHERE     (Stock = CASE @invcode WHEN 1 THEN @A   ELSE <0 END)
Shows conversion error and did not work.
 


Software/Hardware used:
sql server case in query
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    Why are you looking to make your test operation a parameter? Can you state a business case for reason? It would make the code harder to read.
    133,645 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: