If we will execute following XQUERY
sequence script in the sql server:
DECLARE @s AS XML = ''
SELECT @s.query('1,2,a,b')
We may get error
message something like this:
Msg 2210,
Level 16, State 1, Line 2
XQuery [query()]: Heterogeneous sequences are not allowed:
found 'xs:integer +' and 'element(a,xdt:untyped) *'
Cause: Sql server
doesn't support a sequence with different
types. In the above sequence 1 and 2 are of integer type while a and b are
unknown type. All values in a sequence must be of same time.
Solution: Convert
those values to higher data type. We can convert all the values in the sequence
to string. For example:
DECLARE @s AS XML = ''
SELECT @s.query('"1","2","a","b"')
Output:
1 2 a b
No comments:
Post a Comment