| Author |
Topic |
|
ratheeshknair
Posting Yak Master
129 Posts |
Posted - 2008-08-18 : 04:01:00
|
| Hi Experts, How can i insert data into a table from another table.The new table have different column name and in some coulmns i have to insert a default value.Please helpTIARKNAIR |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-18 : 04:12:43
|
| INSERT INTO DestnTable(col1,col2,col3,col4,..)SELECT MatchCol1,DEFAULT,MatchCol2,constvalueFROM SrcTablehere 1 & 3rd fields take data from two fields of SrcTable while second field takes default value. 4th field has constant value |
 |
|
|
ratheeshknair
Posting Yak Master
129 Posts |
Posted - 2008-08-18 : 04:21:01
|
Thanks alot visakh RKNAIR |
 |
|
|
ratheeshknair
Posting Yak Master
129 Posts |
Posted - 2008-08-18 : 05:15:51
|
| hi, I am facing another problem that i have N and Q as values in a column in old table and i want N as 1 and Q as 0 in the new table.What i have to do???RKNAIR |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-18 : 05:22:43
|
| ExINSERT INTO DestnTable(col1,col2,col3,col4,..)SELECT MatchCol1,DEFAULT,MatchCol2,case when constvalue='N' then 1 when constvalue='Q' then 0 else constvalue endFROM SrcTableMadhivananFailing to plan is Planning to fail |
 |
|
|
ratheeshknair
Posting Yak Master
129 Posts |
Posted - 2008-08-18 : 06:25:27
|
Thanks ......... RKNAIR |
 |
|
|
ratheeshknair
Posting Yak Master
129 Posts |
Posted - 2008-08-19 : 04:03:51
|
| Hi , How can i insert three column values together in a single column and i need a space of char(13) in between each column value.TIARKNAIR |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-19 : 04:10:14
|
quote: Originally posted by ratheeshknair Hi , How can i insert three column values together in a single column and i need a space of char(13) in between each column value.TIARKNAIR
coalesce(col1,'')+char(13)+coalesce(col2,'')+char(13)+coalesce(col3,'')MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-19 : 04:11:24
|
quote: Originally posted by ratheeshknair Hi , How can i insert three column values together in a single column and i need a space of char(13) in between each column value.TIARKNAIR
have you tried this yourself before asking? If yes, can we see what you tried? if not, use books online look for INSERT satement for assistance, try it and post if you face any problem. |
 |
|
|
|