I try to execute this query in SQL Server:
select * from users where case when 1=1 then name is null else true end;
But I got this error:
Incorrect syntax near the keyword 'is'
This query works in MySQL successfully. Can you please tell me the equivalent of this query in SQL Server?
You can't do such expression, syntax is wrong.
If you want to choose the condition, you have to play with logical operators:
where (1=1 and name is null)
or (1<>1 and 1=1)
I replaced true
with condition that always evalutes to true ( 1=1
), because true
itself is another synta error in your query.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.