Answered FOR XML

  • 2011년 6월 13일 월요일 오후 7:58
     
     
    For the following query, you want to generate inline XML Schema Definition (XSD) schema using a FOR XML query:
     

    SELECT d.DepartmentID,
    d.Name,
    d.GroupName
    FROM HumanResources.Department d
    WHERE d.DepartmentID IN ( 7, 8 )
    FOR XML raw,
    ELEMENTS

    What changes should you make to the Transact-SQL statement?

    1.Add the keyword XMLDATA  at the end
    2.Add the keyword ELEMENTS.
    3.Add the keyword XMLSCHEMA  at the end
    4.Use the keyword XMLSCHEMA, ELEMENTS.

    According to BOL, to generate inline XML Schema Definition (XSD) schema using a FOR XML query the keyword SMLSCHEMA should be used. according to this option 3 is correct. but the MCTS training says option 1.

    can anyone tell me the correct answer?

    thanks

    lakshmi nair

모든 응답

  • 2011년 6월 13일 월요일 오후 8:04
    중재자
     
     답변됨
    XMLDATA

    Returns inline XDR schema, but does not add the root element to the result. If XMLDATA is specified, XDR schema is appended to the document.

    XMLSCHEMA [ ('TargetNameSpaceURI') ]

    Returns inline XSD schema. You can optionally specify a target namespace URI when you specify this directive, which returns the specified namespace in the schema. For more information, see Inline XSD Schema Generation.

     

    http://msdn.microsoft.com/en-us/library/ms173812.aspx

    So, answer 3 can be considered correct.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

  • 2012년 8월 20일 월요일 오후 9:42
     
     답변됨
    That one was considered the answer??!!  Please try again.  The question specifically asks for an XSD schema.  The XMLDATA option produces an XDR schema.  Two different animals.  The test answer was in error, and to compound the problem you've got an expert on here justifying it, and to compound it further the moderator accepted this???  You cannot produce an XSD schema out of an XMLDATA keyword.  Please correct this.  The given answer is wrong.  Answer number 3 is correct.  Answer number 4 is plausible, but would be marked incorrect by because 3 is the better answer.  Answer 1 is not correct.  It cannot be considered correct from any viewpoint.