Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case statement error

Status
Not open for further replies.

n36z

Programmer
Jul 26, 2011
13
US
When I run the following query. An error is being thrown "Incorrect syntax near 'columnA'"

declare @value1 int
set @value1=2

select *
from table1
where 0 = 0

AND
CASE
WHEN @value1>1 columnA
ELSE 1
END = 1
 
Code:
SELECT * 
FROM table1
WHERE 0 = 0
[tab]1 = AND CASE WHEN @value1 > 1 [!]THEN[/!] columnA ELSE 1 END

Lodlaiden


I haz all the letters: SME, BA, QA, PM, DEV, DBA, UAT, SE, HD
 
declare @value1 int
set @value1=2

select * from table1 where 1 =
CASE
WHEN @value1>1
then columnA
ELSE 1
END
 
Code:
WHERE 0 = 0 AND
      (columnA = 1 OR @value1 < 1)

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top