How do you return a constant from an sql statement?

wusher picture wusher · Nov 20, 2008 · Viewed 52.4k times · Source

How do I return a constant from an sql statement?

For example how would I change the code below so "my message" would return if my (boolean expression) was true

if (my boolean expression)
 "my message"
else
 select top 1 name from people;

I am using ms sql 2000

Answer

Ned Batchelder picture Ned Batchelder · Nov 20, 2008

Did you try:

select 'my message';