MS SQL Server Editor Software questions & answers

Make changes to the data found within MS SQL Server tables
G
Question by Guest
254 views
4

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
D
Answer by Dan Angel

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;
See more questions & answers

Ask a question about MS SQL Server Editor Software

Alternative downloads

MS SQL Maestro
rating

With MS SQL Maestro you can edit and execute SQL scripts.

MS SQL Code Factory
rating

Premier MS SQL Server GUI tool.

EMS SQL Backup for SQL Server
rating

Backup and restore SQL Server databases that includes hot deployment mechanism.