October 29, 2010 at 12:48 pm
I have one table of data with Stock Number, Code, Specs. There are several entries per stock number. I would like to get the stock number then all of the specs combined into one field. Here are the results for one stock number. Is there any way to get this where I can get all of the results (specs) combined into one single field?
ID Stock Code Specs
1 1651566125 1 COFFEE, FOR 12 CUP POUR-OVER TYPE COFFEE BREWER. FILTER
2 1651566125 3 TO BE BLEACHED PAPER TOWELING. FILTER BOTTOM TO BE NO
3 1651566125 5 LESS THAN 3-1/8 INCHES WIDE AND NO MORE THAN ....
October 29, 2010 at 2:00 pm
October 29, 2010 at 2:02 pm
Serial/Quirky update in a temp table, a while loop, or possibly a recursion cte. I don't have time right now to convert your data into a usable test structure.
If you check the first link in my sig in setting up test data you'll most likely get better results, and the code will be tested, to boot.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
October 29, 2010 at 2:09 pm
Pavan as Craig says, please set up some sample data in the form of a CREATE TABLE statement followed by INSERT to populate your table with data. Include at least two partitions (separate ranges) to show that the technique works. Your requirement is common and trivial, proving the solution works is not. All of your data would be ideal but a representative sample is sufficient. Thanks.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
October 29, 2010 at 3:09 pm
I guess what Chris refers to is the FOR XML PATH() concept.
You might find a suitable solution by searching for "string concatenate for xml path" on either this forum or the web.
The "tricky part" (more or less) is to defiine the order the different specs need to be shown.
that's why (I guess) Chris asking your for the sample data.
And I second Chris: provide ready to use sample data, the business rule(s) and your expected result and there will be a number of people willing to help you.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply