Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL Server Table Structure as follows
-------------------
1. CompanyID int,Branches varchar(100)

1. Data for above table is
------------------------------
1 '1,2,3'
2 '2,3'
3 '1,3'

2. BranchID int,BranchName varchar(100)

2. Data for above table is
------------------------------
1 'Sydney'
2 'New York'
3 'Los Angeles'


Q. Required Result from 1st table as without using scalar function
---------------------------------------------------------------
1 'Sydney,New York,Los Angeles'
2 'New York,Los Angeles'
3 'Sydney,Los Angeles'
Posted

See if this solves your problem,

http://mangalpardeshi.blogspot.com/2009/03/how-to-split-comma-delimited-string.html[^]

(You might need to tailor it to meet your custom requirement)
 
Share this answer
 
v2
Your question is similar to this question :

how to create procedue for select two table data[^]

Please change its solution so it fits your needs.
 
Share this answer
 
Pseudocode

1. Declare a variable as cursur
2. Do
3. Fetch the value of Braches (to @val).
4. Get the string value(comma delimited) and use split it(token).
5. SET @strVar = BrachName FROM TBLBraches2 WHERE BrachID = @val
6. PRINT @strVar + ' '
7. Loop(recordcount of cursur)
8.End
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900