[AccessD] SQL Server - Turning comparisons into Booleans

Kenneth Ismert kismert at gmail.com
Tue May 8 19:53:46 CDT 2007


SQL Server can't cast a boolean expression into a boolean type. That's
because SQL Server doesn't really have a boolean data type (at least
as of SQL 2000).

Use a case statement, and return 1 for True, and 0 for False:

CASE WHEN SomeField <=10 THEN 1 ELSE 0 END As MyAlias

-Ken

> In Access you can do something like:
>
> MyAlias: [SomeField] <=10
>
> Which translates into SQL that looks like:
>
> [SomeField]<=10 as MyAlias
>
> When I try move that (cut and paste) from Access into SQL Server I get a the
> infamous "syntax error somewhere near <"
>
> Question 1:  What is wrong with that in SQL Server
> Question 2: How do I accomplish this directly in the query builder in SQL
> Server?
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>



More information about the AccessD mailing list