• XML data type can store XML DOCUMENTS (having exactly 1 root element) and XML CONTENT (having 0 or more top level elements). The default is CONTENT and hence it allows 0 or more top level elements. The schema performs a validation only if the element is present.

    Declare your XML variable as DOCUMENT and then SQL Sever will perform the validation that you expect. For example:

    DECLARE @x XML(DOCUMENT EmployeeSchema)

    .