Advertisement

01.03.2008 at 08:59AM PST, ID: 23055996
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Return xml data (element based) from stored procedure SQL Server 2000 - help needed

Asked by gbzhhu in SQL Server 2008, Extensible Markup Language (XML), Microsoft Visual C#.Net

Tags: , , , ,

I am trying to retrieve simple data from 2 related tables in SQL.  I want the data in XML format without using the FOR XML clause.

I would like the data to be in this format

<module>
    <id>1</id>
    <name>module name</name>
    <desc>blah</desc>
    etc..
</module>
<module>
    <id>2</id>
    <name>module name 2</name>
    <desc>blah 2</desc>
    etc..
</module>

I have this stored proc but iot doesn't return correct xml format

ALTER PROCEDURE dbo.elearning_get_modules
      @userId int
AS
      SET NOCOUNT ON

      SELECT       DISTINCT
                  1 AS Tag,
                  NULL AS Parent,                  
                  EXM.id AS [module!1!id],
                  NULL AS [module!2!moduleName],
                  NULL AS [module!2!description],
                  NULL AS [module!2!url],
                  NULL AS [module!2!basis],
                  NULL AS [module!2!nroso],
                  NULL AS [module!2!dateCompleted]
      FROM dbo.elearning_xref_modules EXM
      LEFT OUTER JOIN elearning_user_completed_modules EUCM ON EXM.id = EUCM.ModuleId
      AND EUCM.UserId = @UserId
      
      UNION ALL
      
      SELECT       DISTINCT
                  2 AS Tag,
                  1 AS Parent,                  
                  EXM.id AS [module!1!id],
                  EXM.moduleName AS [module!2!moduleName],
                  EXM.description AS [module!2!description],
                  EXM.url AS [module!2!url],
                  EXM.basis AS [module!2!basis],
                  EXM.nroso AS [module!2!nroso],
                  EUCM.dateCompleted AS [module!2!dateCompleted]
      FROM dbo.elearning_xref_modules EXM
      LEFT OUTER JOIN elearning_user_completed_modules EUCM ON EXM.id = EUCM.ModuleId
      AND EUCM.UserId = @UserId
                  
      ORDER BY Tag, Parent, [module!1!id]
 
      RETURN

Help much appreciated

HStart Free Trial
[+][-]01.03.2008 at 11:03PM PST, ID: 20580387

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2008, Extensible Markup Language (XML), Microsoft Visual C#.Net
Tags: xml, return, procedure, stored, sql
Sign Up Now!
Solution Provided By: techbie
Participating Experts: 3
Solution Grade: A
 
 
[+][-]01.05.2008 at 04:13AM PST, ID: 20588894

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.05.2008 at 04:14AM PST, ID: 20588897

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.05.2008 at 07:52PM PST, ID: 20592424

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.08.2008 at 02:09AM PST, ID: 20607194

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628