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 |
sharona
Yak Posting Veteran
75 Posts |
Posted - 2011-09-22 : 10:09:53
|
i have an update query that updates my values into columnsas shown below;(the * seperate the columns)ACTIONCODE ******* _BCP *****ABACAddCashAccounts *****ITA *****FR AddCounterparty *****TDM *****ITA AddEditBroker ******* ID *****TDM AddNewDeal ********SET *****ITA AddServicer ********ITA *****TDM AddToMasterWhatIf ***TD *****ITA AdjustmentScreen ***ITA ***** TDM AdjustProductStatic **SET ***** FR AllowArchive ******ITA ***** MGR sometimes the action code can have multiple _bcp and abachow do i insert multiple values into one column?currently in AddCashAccounts under _BCP it shows ITA i would like to see FR, ITA below is my scriptCREATE TABLE #FINAL( FUNDCODE VARCHAR(4), ACTIONCODE VARCHAR (24), ROLECODE VARCHAR(4), _BCP VARCHAR(24), ABAC VARCHAR(24))-- GET ALL FUNDS ---SELECT DISTINCTR.FUNDCODE,R.ACTIONCODE,R.ROLECODEINTO #FUNDfrom dbo.RoleAction Rwhere R.FundCode IN ('_BCP','ABAC')GROUP BY R.ACTIONCODE,R.ROLECODE,R.FUNDCODE--Add all data to the final tableINSERT #Final( ACTIONCODE, ROLECODE)SELECT DISTINCT ACTIONCODE, ROLECODEFROM #FUND -- Update final tableUPDATE #FinalSET _BCP = R.ROLECODEFROM #fund r, #Final fWHERE f.ACTIONCODE = r.ACTIONCODE AND r.FUNDCODE = '_BCP'UPDATE #FinalSET ABAC = R.ROLECODEFROM #fund r, #Final fWHERE f.ACTIONCODE = r.ACTIONCODE AND r.FUNDCODE = 'ABAC'----Final selectselect distinct ACTIONCODE, _BCP, ABACfrom #FINALgroup byACTIONCODE,_BCP,ABAC--DROP TABLE #FUND--DROP TABLE #Final |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-16 : 05:38:33
|
You can update column with concatenating other column values likeupdate tableset col1=col2+','+col1MadhivananFailing to plan is Planning to fail |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|