An expression of non-boolean type specified in a context where a condition is expected, near '@orderwhere'
sql, sql-server, syntax
Solution
You can't have parts of your query being dynamic. It has to be all or nothing. Then use EXEC() to run your dynamic query
exec('select order_status.order_id
from order_status
where ' + @orderwhere)
Problem
Why is the following syntax generates the error "An expression of non-boolean type specified in a context where a condition is expected, near '@orderwhere'" ``` use orders declare @orderwhere varchar(5000) set @orderwhere = 'order_status.step = 1' select order_status.order_id from order_status where @orderwhere ```