Original Table
Col_1 --Col_2
DE
DE
XB
DE
C
XB
D
XB
I want to obtain this
Col_1 --Col_2
DE----1
DE----1
XB----2
DE----1
C----3
XB----2
D ----4
XB----2
or this
Col_1 --Col_2
DE---- 1
XB----2
C----3
D----4
Is possible without use cursors ?Originally posted by Ovidiu
Original Table
Col_1 --Col_2
DE
DE
XB
DE
C
XB
D
XB
I want to obtain this
Col_1 --Col_2
DE----1
DE----1
XB----2
DE----1
C----3
XB----2
D ----4
XB----2
or this
Col_1 --Col_2
DE---- 1
XB----2
C----3
D----4
Is possible without use cursors ?
on what basis u r trying to assign col_2 values?
is it just any sequence ?|||I sort the table ... ORDER BY col_1 (in reality more that one column)
The col_2 is empty / Null and I want to update the col_2 with this value: 1, 2, 3 ,4 ........|||Originally posted by Ovidiu
I sort the table ... ORDER BY col_1 (in reality more that one column)
The col_2 is empty / Null and I want to update the col_2 with this value: 1, 2, 3 ,4 ........
declare table @.Temp(col_1 type,col_2 int identity(1,1))
insert @.temp select distinct col_1 from originaltable order by col_1
update originaltable set col_2=t.col_2 from originaltable as ot join @.Temp as t on ot.col_1=t.col_1|||Thanks
Monday, March 26, 2012
Easy question
Labels:
col_1,
col_2,
col_2dedexbdecxbdxbi,
database,
de-1,
de-1xb-2de-1c-3xb-2d,
microsoft,
mysql,
obtain,
oracle,
original,
server,
sql,
tablecol_1,
xb-2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment