# Miscellaneous > Ask an Expert >  MS SQL stored procedure

## jerrygpc

I am creating a stored procedure to create
a detail report.  One of the columns to appear on
the report is actually based on whether data is
in one column or another.

Example:

Along with selecting other columns,
I want to 'select' column_A if column_A
is greater than spaces, but if it is not
greater than spaces, I want to 'select'
column_B.  I've tried 'IF' statements in
combination with 'SELECT' statments, but
I get various errors.  Do you know of
a way I can do this?

Thanks

----------


## MAK

select column1, column2, Newcolumn = case when column_A>spaces then column_A else column_b end from mytable

check BOL for syntax

----------

