SELECT
ProjectID, Description, TargetDate
FROM dbo.ProjectWHERE MaterialList.exist
('/Materials/Item/SKU[@ID="XS-7"]')
AND CompletionDate IS NULL;
This query will return an error because the exist() method returns a value of 0 or 1.
This query will generate the following error:
Msg 4145, Level 15, State 1, Line 7
An expression of
non-boolean type specified in a context where a condition is expected, near
'AND'.DBA/Developer
should not use the following query:SELECT *, MaterialList.query ('Materials/Item/SKU[@ID="XS-7"]')
FROM dbo.Project;
This query will return a row for all projects because no WHERE clause was specified. For products with a material list including the XS-7 item, it would return a single <SKU> element as follows:
<SKU ID="XS-7" ItemDesc="Wall Brackets" />
DBA/Developer should not use the following query:
SELECT ProjectID, Description,
TargetDate
FROM dbo.ProjectWHERE MaterialList.query
('/Materials/Item/SKU[.="XS-7"]')
AND CompletionDate IS NULL;
The query() method is used to query and retrieve XML elements and attributes from an XML instance. The method accepts a string XQuery expression that determines which elements and element attributes are extracted. It will return untyped XML, not a Boolean value that can be referenced in a WHERE clause. This query will return the following error:
Msg 4145, Level 15, State 1, Line 5
No comments:
Post a Comment