| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Break up a field into multiple rows
Thanks, this makes sense. My only problem is that I cannot write this
as a view in MS SQL server. Any one know why? It simply errors out
and complains that there are no output columns or from clause.
Todd
"Tibor Karaszi" <tibor_not_pressed_ham_.karaszi_at_cornerstone.se> wrote in message news:<Ewvu9.1454$1r1.44981_at_newsc.telia.net>...
> Todd,
>
> Here's a "brute force" method, using some string manipulation and a UNION.
> Dialect is MS Transact-SQL. The CHARINDEX function find the position of the
> first expression within the second expression.
>
> SELECT
> order_number
> ,sales_rep
> ,item
> ,quantity
> ,LEFT(territories, CHARINDEX(' ', territories))
> FROM sales_orders
> UNION ALL
> SELECT
> order_number
> ,sales_rep
> ,item
> ,quantity
> ,RIGHT(territories, CHARINDEX(' ', territories))
> FROM sales_orders
>
> --
> Tibor Karaszi
Received on Wed Oct 30 2002 - 12:00:13 CST
![]() |
![]() |