Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Insert a new Column using SELECT
Fri, Jan 20 2006 6:28 AMPermanent Link

"Jack Marsh"
Hi,

I have a simple query that creates a table using

SELECT ContactCode, ContactName FROM Contacts

I would like the results table to insert an additional boolean column, with
every record defaulting to 'True'.

Is this possible and, if so, how?

Thanks
Jack

Fri, Jan 20 2006 6:41 AMPermanent Link

"Ole Willy Tuv"
Jack,

<< I have a simple query that creates a table using

SELECT ContactCode, ContactName FROM Contacts >>

You mean creates a result set ?

<< I would like the results table to insert an additional boolean column,
with every record defaulting to 'True'. >>

SELECT
 ContactCode,
 ContactName,
 CAST('True' AS BOOLEAN)
FROM Contacts

Ole Willy Tuv

Fri, Jan 20 2006 6:54 AMPermanent Link

"Ole Willy Tuv"
I didn't think of it at first, but you can also use the boolean literal
True:

SELECT ContactCode, ContactName, True
FROM Contacts

Ole Willy Tuv

Fri, Jan 20 2006 8:01 AMPermanent Link

"Robert"

"Ole Willy Tuv" <owtuv@online.no> wrote in message
news:E6DE4EC1-86A4-45EE-BFAB-6DC9F448E801@news.elevatesoft.com...
>
> SELECT
>   ContactCode,
>   ContactName,
>   CAST('True' AS BOOLEAN) MyField

you will need a name for the field.

Robert

Fri, Jan 20 2006 8:28 AMPermanent Link

"Jack Marsh"
Thanks guys, works a treat!

Cheers,
Jack

"Ole Willy Tuv" <owtuv@online.no> wrote in message
news:E6DE4EC1-86A4-45EE-BFAB-6DC9F448E801@news.elevatesoft.com...
> Jack,
>
> << I have a simple query that creates a table using
>
> SELECT ContactCode, ContactName FROM Contacts >>
>
> You mean creates a result set ?
>
> << I would like the results table to insert an additional boolean column,
> with every record defaulting to 'True'. >>
>
> SELECT
>  ContactCode,
>  ContactName,
>  CAST('True' AS BOOLEAN)
> FROM Contacts
>
> Ole Willy Tuv
>
>

Fri, Jan 20 2006 8:50 AMPermanent Link

"Ole Willy Tuv"
> you will need a name for the field.

Why ?

Ole

Fri, Jan 20 2006 9:18 AMPermanent Link

"Robert"

"Ole Willy Tuv" <owtuv@online.no> wrote in message
news:65DE3F0D-BA68-4BA3-9948-4542AD7401EF@news.elevatesoft.com...
> > you will need a name for the field.
>
> Why ?
>

Well, I think it is better to name the field. You don't HAVE to.

Robert

> Ole
>
>

Image