|
View previous topic :: View next topic
|
| Author |
Message |
santhunaveen
New User
Joined: 22 Sep 2006 Posts: 33
|
|
|
|
hi,
I have a table1 and columns like,
R_cd C_cd C_SRC_CD C_HDR_TY_CD
0014 A 8 1
0014 A 8 2
0025 A 8 C
0025 A 8 E
0025 A 8 K
0025 A 8 L
0025 A 8 M
0025 A 8 P
0025 A 8 S
0025 A 8 T
0025 C 8 C
0025 C 8 E
0025 C 8 H
0025 C 8 I
0025 C 8 K
0025 C 8 L
...................................
Like this I have around 10,000 rows in mytable....
now my requirement is wherever the C_SRC_CD value is '8', I have to insert below 1 row same as above values except C_SRC_CD should be '1' in the pace of 1.....(for reference i have bolded that value '1')
My o/p should be like this......
R_cd C_cd_ C_SRC_CD C_HDR_TY_CD
0014 A 8 1
0014 A 1 1
0014 A 8 2
0014 A 1 2
0025 A 8 C
0025 A 1 C
0025 A 8 E
0025 A 1 E
0025 A 8 K
0025 A 1 K
0025 A 8 L
0025 A 1 L
0025 A 8 M
0025 A 1 M
0025 A 8 P
0025 A 1 P
0025 A 8 S
0025 A 1 S
0025 A 8 T
0025 A 1 T
0025 C 8 C
0025 C 1 C
0025 C 8 E
Can any one please help me throuugh SQL how can I do this.........
It's high priority task plz hepl me........ |
|
| Back to top |
|
 |
vini_srcna
Active User

Joined: 26 May 2005 Posts: 178 Location: Copenhagen, Denmark
|
|
|
|
I assume C_SRC_CD is Numeric datatype.
INSERT INTO tablename(R_cd,C_cd,C_SRC_CD, C_HDR_TY_CD)
SELECT R_cd,C_cd,1, C_HDR_TY_CD FROM tablename
WHERE C_SRC_CD = 8 ;
If C_SRC_CD is CHAR then put it in quotes.
I have not tested this. Let me know what happens.. |
|
| Back to top |
|
 |
santhunaveen
New User
Joined: 22 Sep 2006 Posts: 33
|
|
|
|
hi,
Thanks it's working..... |
|
| Back to top |
|
 |
|
|