durai nagarajan (8/20/2012)
if you want the result like thisTranIDCode
201205AMDDOH
201206IXJRMI
then the query should be
select TranID , OriginCode + DestinationCode 'Code' from #Test
if this is not as per your output post a detailed explaination.
No that won't give the concatenation that the OP is after, we are looking for a distinct row for TranID with the concatenation of Code and Destination in ID (hierarchical) order
201205AMDDOHNBOADDDELAMD
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe