troubleshooting Question

Numeric Check MSSQL 2005

Avatar of dinesh_bali
dinesh_bali asked on
Microsoft SQL Server 2005
6 Comments1 Solution379 ViewsLast Modified:
Hi,

I am working on MSSQL 2005

I want in table TMPMATERIALORDERED field Quantity should be numeric and greater than 0, if not than the

STATUS should be set to FAILURE and REMARKS should be set to Quantity is not numeric or Quantity is less than 0

In table TMPMATERIALORDERED my filed Quantity is nvarchar(100)

My query gives error says

Msg 4145, Level 15, State 1, Line 3
An expression of non-boolean type specified in a context where a condition is expected, near 'Then'.

Please find my query below and help me in correcting it


Update TMPMATERIALORDERED
Set STATUS = Case
  When Not IsNumeric(Quantity) Then 'FAILURE'
  When IsNumeric(Quantity) And Quantity <=0 Then 'FAILURE'
  Else NULL
End,
Set REMARKS = Case
  When Not IsNumeric(Quantity) Then 'Quantity is not numeric'
  When IsNumeric(Quantity) And Quantity <=0 Then 'Quantity is less than 0'
  Else NULL
End
 

WHERE
      QUANTITY IS NULL
      AND STATUS IS NULL
      
      
Please Help
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros