Saturday, February 25, 2012

changing one column in each row

ie if i have

x 1 2 3 4 5
----
1| a b c d e
2| f g h i j
3| k l m n o
4| p q r s t
5| u v w x y

and i want to change it to

x 1 2 3 4 5
----
1| a b c d e
2| a b c d e
3| a b c d e
4| a b c d e
5| a b c d e

any ideas on how to do that?Hi, Zellos!

ZM> any ideas on how to do that?

have one:
update t
set t.fld1=t2.fld1,
t.fld2=t2.fld2,
t.fld3=t2.fld3,
t.fld4=t2.fld4,
t.fld5=t2.fld5
from table1 t, (select top 1 * from table1) t2

-
xexe!|||"Zellos Mokozu" <me@.zellos.net> wrote in message
news:a20163e6.0405251825.33e6abe3@.posting.google.c om...
> ie if i have
> x 1 2 3 4 5
> ----
> 1| a b c d e
> 2| f g h i j
> 3| k l m n o
> 4| p q r s t
> 5| u v w x y
>
> and i want to change it to

I'm confused. Why not simply, Update foo set 1='a', 2='b', 3='c', 4='d',
5='e'

It looks like all your rows are the same.

> x 1 2 3 4 5
> ----
> 1| a b c d e
> 2| a b c d e
> 3| a b c d e
> 4| a b c d e
> 5| a b c d e
> any ideas on how to do that?

No comments:

Post a Comment