unit testing - Boolean Expressions in SQL Select list -


I want to make a SQL selection to test a unit in MS SQL Server 2005. The basic idea is this:

Select 'Test Name', 'foo =' Result Bar from where baz = (some criteria)

The idea is that, if "foo" The value of the column "results", then I get the value of the right 1/1; If not, then I will get false / 0.

Unfortunately, T-SQL does not like the expression; It suppresses the equal sign.

Is there any way to evaluate an expression in the SQL Selection list and get results back? (Or are there some other ways I should get the unit test that I want?)


EDIT: 3 Great, answer, all created around the case. I'll accept feihtthief because he's got the least representative and thus it needs the most :-) Thanks for everyone.

Use case generation:

  'test name' Select when foo = 'Result', then end with 1 and 0 times where baz = (some criteria)  

Also see.


Comments