January 25, 2008 at 2:26 pm
Need a little assistance creating a SQL statement to put the results in a particular format...
the format I am looking for in the result is
DataSet1
subData, subData, subData
subsubData, subsubData, subsubData
DataSet2
subData, subData, subData
so in real terms I have a product database I woul like to "group" the results by product name, the the product belongs to several sections and also several categories so is it possible in t-sql to group the result set to return like so
ProductName
categoryName | categoryName | categoryName
sectionName| sectionName |sectionName
-----------------------------------------------------------------------
ProductName
categoryName | categoryName |categoryName
sectionName, sectionName, sectionName
Or do i really need to bring this into a presentationlayer?
January 26, 2008 at 4:38 am
You could output as XML and then pass it on to the presentation layer, but it'd probably be a lot easier overall to format the output on the app.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 26, 2008 at 4:43 am
It could be done in MS SQL but I'd very strongly recommend you do it in the application. Just return the three datasets (you can even order them if you like to make presentation processing easier) from the procedure. It will be much easier to program, debug and modify in the future. If you really really need a T-SQL approach then can you explain the relationship between categories and sections - are there multiple sections in a category or are categories and sections both properties of the product and are otherwise unrelated??
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply