Re: Creating "multiple" rows manually with SELECT
- From: Charley Hanania <Charley.Hanania@xxxxxxxxxxx>
- Date: Mon, 5 Oct 2009 18:27:09 +0000 (UTC)
Hi there,
You should use the UNION ALL Clause. vis.
SELECT * FROM (SELECT 'Apple' AS FRUIT
UNION ALL
SELECT 'Banana' AS FRUIT
UNION ALL
SELECT 'Cherry' AS FRUIT) A
Hope this helps,
Charley Hanania
Hi All,
In T-SQL is there a way for a subquery to manually create multiple
rows?
i.e.
If I don't have the luxury building a temp table on-the-fly, is there
a way to create rows?
e.g.
If I want an intermediate table to have
Apple
Banana
Cherry
in 3 rows with a column called FRUIT,
is there a way to do that on the fly?
Example, you can create one row such as:
select *
from (
select 'Apple' as fruit
) as a
But is there a way to get three (or more) rows?
Thanks in advance.
.
- References:
- Prev by Date: Re: Creating "multiple" rows manually with SELECT
- Next by Date: RE: Creating "multiple" rows manually with SELECT
- Previous by thread: Re: Creating "multiple" rows manually with SELECT
- Next by thread: RE: Creating "multiple" rows manually with SELECT
- Index(es):
Relevant Pages
|