SQL Script when using XL Report Generator

0 votes
asked by about MS SQL Server Editor Software
edited by

The script below generates a syntax error (missing operator). Can you help me? "Param1" can either be a "0" or "1".

select Bidders.*
From Bidders
where
If (:Param1 = 1) Then
   Due > 0 and
   Left(Event,2) <> 12
Else
   Due = 0) and
   Left(Event,2) <> 12
End If
order by
      Name

1 Answer

0 votes
No avatar answered by (132k points)

In order to fix the problem, I recommend you rewrite the query using the following code:

select Bidders.*
From Bidders
where (:Param1 = 1 and Due > 0 and Left(Event,2) <> 12) or
      (:Param1 <> 1 and Due = 0 and Left(Event,2) <> 12)
order by Name;

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...