Need help relating data without relationship (many 2 many)

I have the following data in two tables. I'd like to populate ColumnApps in Table1 with all the apps from Table2.  However the technique needs to be able to pickup a multi valued cell.  If there's no solution with a multi value cell how can I split the data out to get what I need?

Table1:

ColumnServer ColumnApps
------------ ---------------
ServerA Need to populate this, can be multi value
ServerB
ServerC

Table2:

ColumnApp ColumnServers
--------------- -------------------
App1 ServerB,ServerC
App2 ServerA,ServerB
App3 ServerA,ServerC


  • Edited by JonSykes Friday, March 27, 2015 2:11 PM
March 27th, 2015 2:08pm

Declare @column varchar(100) = 'SERVERB,SERVERC,SERVERA'
  Select @column YourColumn,
              PARSENAME(REPLACE(@column,',','.'),3)'Second',
              PARSENAME(REPLACE(@column,',','.'),2)'Third',
              PARSENAME(REPLACE(@column,',','.'),1)'Fourth'

OR 

select * from Table1 cross apply  Table2

Thanks

--------------------------------------------------------------------------------------------------

Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers


Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 2:24pm

Declare @column varchar(100) = 'SERVERB,SERVERC,SERVERA'
  Select @column YourColumn,
              PARSENAME(REPLACE(@column,',','.'),3)'Second',
              PARSENAME(REPLACE(@column,',','.'),2)'Third',
              PARSENAME(REPLACE(@column,',','.'),1)'Fourth'

OR 

select * from Table1 cross apply  Table2

Thanks

--------------------------------------------------------------------------------------------------

Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers


I should have mentioned that table1 is in powerpivot within excel.  The data is initially pulled from sql.  However table2 is data from an excel spreadsheet.
March 27th, 2015 3:17pm

Jon, have you made any progress on this?

Thanks!

Free Windows Admin Tool Kit Click here and download it now
May 1st, 2015 4:33pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics