Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have vendor column name and there is data is saved bellow pattern
vendor
1|2|3
45|85|66
and I want excepted output is
vendor
1
2
3
45
85
66
Posted

1 solution

The simple answer is: don't. Don't store data as concatenated strings, use a separate table to cross reference your vendors with the products they vend. It seems like more work to set up (and it is) but it saves a huge amount of time later - as you are starting to see. It's a lot easier to change that now - before you have a mass of code and data built up - than it is to decide you need to to it later when you have a huge task to sort it out.

But...you can do it, if you must. It's just horribly, horribly messy:
Converting comma separated data in a column to rows for selection[^]

Seriously, change your DB layout now and the queries all become simple JOINs (which SQL server is very, very good at processing - string manipulation is not its forte, and is very slow as a result)
 
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