Sql – Boolean expression in SQL

sql-server

I have two ints: @RecurremceTemp and @WeekDifference

The following line errors:

PRINT @WeekDifference >= @RecurrenceTemp

with Incorrect syntax near '>'

And won't execute.

Can someone please tell me how to write such a boolean expression to include in a Select statement i.e.:

Select * 
FROM TableX 
WHERE somevariable = x 
and @WeekDifference >= @RecurrenceTemp

Best Solution

Predicates cannot be used in expressions, only in IF and WHILE and CASE WHEN:

PRINT CASE WHEN @WeekDifference >= @RecurrenceTemp THEN 1 ELSE 0 END