1

Can you help me on this one.I'm trying to pull data from the database of a CAD software and I wish to make a temporary table from the given table below(the output temptable is also shown below) so that i can join it to my already created table1. I'm new to SQL and it seems that a temporary table could work but i don't know how to append the data from the other row into the first row such that the behavior is similar to a sum() function but working with text. Since i cannot post pictures yet, bear with me the formatting of the original table. and the temptable i wish to make. Thanks in advance

orignal table

----Oid----               ----Cable Tray----

--0010f---                ---mv001---

--0010f---                ---mv002---

--0010f---                ---mv003---

--020ab---                ---lv001---

--020ab---                ---lv002---

output temptable

----Oid----               ----Cable Tray Route---

--0010f---                ---mv001, mv002, mv003---

--020ab---                ---lv001, lv002---

This is my sample code:

select *
from table1
join temptable on temptable.oid=table1.oid
kostas ch.
  • 1,960
  • 1
  • 17
  • 30
  • 1
    A well phrased question with enough information, welcome to Stack! This just doesn't seem like a good idea, you're de-normalizing the data which will make subsequent queries/analysis problematic. However, if you must: this can be accomplished using FOR XML PATH as in the associated link http://stackoverflow.com/questions/12559551/sql-server-equivalent-of-wm-concat-function or http://stackoverflow.com/questions/1621747/concat-field-value-to-string-in-sql-server – xQbert Mar 26 '14 at 13:55

0 Answers0