What am I doing wrong in this SQL Server 2005 case statement?

Soldato
Joined
16 Nov 2003
Posts
9,682
Location
On the pale blue dot
Consider the following code, which works:

Code:
SELECT
	CASE AuditKey
		WHEN 1 THEN 'Foo'
		ELSE 'Bar'
	END
FROM
	Audit

Now lets say I want to test for when the audit key is between 1 and 10. I've tried various bits of syntax but all say 'Incorrect syntax near the keyword 'BETWEEN''. Here are some of my attempts:

Code:
SELECT
	CASE AuditKey
		WHEN BETWEEN 1 AND 10 THEN 'Foo'
		ELSE 'Bar'
	END
FROM
	Audit

SELECT
	CASE AuditKey
		WHEN AuditKey BETWEEN 1 AND 10 THEN 'Foo'
		ELSE 'Bar'
	END
FROM
	Audit

I must be missing something obvious, any ideas?
 
Back
Top Bottom