I have an 8-digit TEXT field (called Code) and want to do a select “where Code mod 3 is 0”.
How do I write this where clause in ms-sql, in particular? I believe the query should be the same in other versions of SQL. Thanks.
I have an 8-digit TEXT field (called Code) and want to do a select
Share
Firstly – DONT DO THIS! Putting scalar calculations in where clauses makes them non-SARGable which effectively means you can’t use indexes and have to do table scans.
Secondly – DONT DO THIS! If any of your codes can’t cast to an INT then this will fail.
Thirdly – If you still want to do this despite the two warnings, this is how: