Home > Archive > Microsoft SQL Server forum > April 2006 > XQuery vs OpenRowset









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XQuery vs OpenRowset
Shilpa

2006-04-05, 9:30 am

Please let me know the advantages and disadvantages of XQuery vs
OpenRowSet in SQL Server 2005. Which would be better?

Regards,
Shilpa

Erland Sommarskog

2006-04-05, 8:26 pm

Shilpa (shilpa.nagavara@unisys.com) writes:
> Please let me know the advantages and disadvantages of XQuery vs
> OpenRowSet in SQL Server 2005. Which would be better?


I'm by no means an expert on XML, but I would say that XQuery is
preferrable for all new code that you write. It may not be worth
to rewrite legacy code just for the sake of it.

A major advantage is that you don't need this sp_xml_preparedocume
nt
with XQuery.

Of course, if all you want to do is to unpack an XML document, using
nodes() and CROSS APPLY may feel bulkier, at least initially when the
new syntax may feel akward. Then again, XQuery permits you to do a
lot more things that OPENXML does not, so that you can query an XML
document withour shredding it.

There is one situation you will have to stick to OPENXML, and that is
if you for for some reason are running with any of the options
QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_WARINGS, ANSI_PADDING or
CONCAT_NULL_YIELDS_N
ULL off. They must be on for XQuery. Note that some
of these options are sticky with stored procedures or table columns.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com