SqlShare.com Logo
 
Skip Navigation Links
Home
Video List
Events
Classes
About Us
Login / Register
Subscribe RSS Feed 

Confio Ignite

Filtering XML Elements using the Exist Method

SQL Server 2005 introduced the XML data type and a number of methods to query the XML datatype. This video shows you how to filter xml elements using the Exist method.

Duration:
2 mins 0 secs
Skill Level:
100
Rating:
4.10 out of 5
Publish Date:
November 03, 2008
Filtering XML Elements using the Exist Method You must be logged in to view this video.  
Bookmark and Share
 
1=Poor, 3=Good, 5=Excellent

About the Author

Image of Plamen Ratchev
Plamen Ratchev has over two decades experience in the software architecture and development field. He has enjoyed building solutions for UNIX, DOS and Windows platforms, with main focus on SQL Server since version 4.21. Plamen is founder of Tangra, specializing in relational database applications analysis, implementation, and tuning. His particular interest is in design patterns, performance a...

References



Comments
Hilary Cotter on 12/17/2008
Short to the point, and focused:)

Michael on 1/9/2009
Would have been helpful to have a bit more explanation of the syntax, especially for the xml WHERE clause.

Plamen Ratchev on 1/10/2009
Michael, the format of the video is too short to go into detailed discussion of using XML methods in predicates. If you are interested here is a good article that covers more details on the XML methods: http://msdn.microsoft.com/en-us/library/ms345117.aspx. Also, if you are interested, the following article covers more details on using appropriate XML indexes for those predicates: http://msdn.microsoft.com/en-us/library/ms345118.aspx.

sachin on 2/6/2009
excellent demo

Team FAB on 8/3/2009
I thought the query was going to say where the data element = 2, but it the query said = 1, I think I will need to watch it again to understand what is happening.

Joe Tigeleiro on 8/3/2009
very good to the point with good example

George Squillace on 8/3/2009
The balloon flashed too quickly. Thanks for the example.

Plamen Ratchev on 8/4/2009
Team FAB, if you watch closely you will see inside the exist() method the value 2 is compared to the customer id, but the exist() method is checked for 1, because exist() returns 1 (true), 0 (false), or NULL.

Travis on 8/5/2009
Good video on XML data comparison, but it would have been nice if code was provided...

Adam Gojdas on 8/7/2009
To add to this you can also do the following to help improve the code: DECLARE @id int SET @id = 2 --and have the WHERE clause be like this: WHERE T.customer.exist('id/text()[. = sql:variable("@id")]') = 1; check out link http://msdn.microsoft.com/en-us/library/ms345118(SQL.90).aspx#sqloptxml_para

Steve Harris on 8/24/2009
Was complete in what it told you but very confusing on how parse XML data. More specifically, the strange formatting structure of using EXIST in the WHERE clause.

Plamen Ratchev on 8/25/2009
Steve, Here is article with more details on the XQuery capabilities in SQL Server and more examples of using the Exist() method in the WHERE clause: http://msdn.microsoft.com/en-us/library/ms345117(SQL.90).aspx

Tonci on 11/27/2009
Excellent!

Tonci on 7/19/2010
great!

Dean Gross on 10/13/2010
the pop up explanation was a good enhancement

manjeet on 11/8/2010
good

karim on 11/8/2010
excellent, you mix sql and xpath langage in the where condition. Good

David on 11/8/2010
Could have explained the syntax a little more. It's pretty wierd code.

Jamshid Nouri on 11/8/2010
great short demo

Mark Hathaway on 11/8/2010
Need more XML insruction.

David Burnett on 11/8/2010
example was too simple and speakers pronounciation was hard to understand.

Indira on 11/8/2010
Informative video. Until now I didn't know that we can use xml data like this.

John on 11/8/2010
not sure what happens if reading from xml file though

Raymond on 11/8/2010
Thanks.

kalapala baburao on 11/8/2010
om

Dawit on 11/9/2010
Good job man. A tidy and simple example.

Kasey Wheeler on 11/9/2010
Nice video.

Jack Pines on 11/9/2010
Great material but I think I need a primer on XML Query as this moved a bit fast for me.

Yelena on 11/9/2010
The quality of video was not great. Something wrong with streaming. The information is valuable in any case.

Sridhar on 11/9/2010
This is really excellent article for the SQL Script and XML.

A43036427E on 11/9/2010
Presenter's accent a little hard to follow.

Leigh Anne on 11/11/2010
This one was over my head.

krishnaroopa on 11/23/2010
Good Example. I have requirement that where clause will be defined dynamically and I need to check whether the record exists. eg: 'id/text()[. = "2"]' will be in a sql variable?

Plamen Ratchev on 11/24/2010
Krishnaroopa, yes you do need to use sql:variable to pass the value dynamically. Something like: exist('id/text()[. = sql:variable("@value")]') = 1

Talha on 11/24/2010
please post more videos on XML datattypes

Talha on 11/24/2010
please post more videos on XML datattypes

Dean Gross on 11/26/2010
it would have been better if it included a more complex filter scenario

Jacquelyn Knapp on 12/28/2010
Hard to understand speaker

Anil Babu on 6/16/2011
nice

joseph on 12/28/2011
Good article

madhavi on 12/28/2011
good

William on 12/28/2011
Well-explained, simple example of querying using XML commands. Would like the author to provide more videos on this topic.

Dennis Wetherall on 12/28/2011
You are a great teacher! Thanks for posting.

nice video

Brian Savoie on 12/31/2011
XML parsing is hideous in tsql!! Thanks for the lesson.

Frank on 1/2/2012
GOOD

Ewerton Silveira on 12/1/2012
bad english



Must Be Logged In
 

How Do I Become a Video Author? |  Newsletter History

Copyright © Fourdeuce, Inc., 2005-2009. All Rights Reserved | Privacy Policy | Terms & Conditions