Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
milgurung@hotmail.com
Starting Member
3 Posts |
Posted - 2008-11-14 : 09:38:58
|
| Hi all,Could you please help me to move data from one table to another? It's a bit tricky. a. Table A has 2 colums 1.map 2. AmountB. Table B has 3 columns 1. TAmount 2. GAmount 3. PAmountNow depeding upon the value of "map" column, data needs to be moved to either TAmount or GAmount or PAmount.e.g if "map" = T then TAmount columns is filled and rest are null if "map" = G then GAmount columns is filled and rest are null/emptyAny suggestion is appriciated? I am looking a solution based onINSERT INTO TableB(TAmount,GAmount,PAmount)SELECT ....FROM TableAThanks.Sim. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-14 : 10:12:57
|
INSERT TableB (tAmount, gAmount, pAmount)SELECT CASE WHEN map = 't' then amount ELSE NULL END,CASE WHEN map = 'g' then amount ELSE NULL END,NULLFROM TableA E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|