一些操作符
DECLARE @x XML
SELECT @x = '
<Peoples>
<People NAME="周星驰"/>
<People NAME="刘德华"/>
<People NAME="周杰伦"/>
</Peoples>'
SELECT @X.query('(/Peoples) ')
/*
<Peoples>
<People NAME="周星驰" />
<People NAME="刘德华" />
<People NAME="周杰伦" />
</Peoples>
*/
SELECT @X.query('(/Peoples/People[last()]) ')
/*
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People[.]) ')
/*
<People NAME="周星驰" />
<People NAME="刘德华" />
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People[. >> (/Peoples/People[@NAME="周星驰"])[1]]) [last()] ')
/*
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[last()]] )')
/*
<People NAME="周星驰" />
*/
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[1]] )')
/*
<People NAME="周星驰" />
*/
SELECT @X.query('( . is .)')
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[1]] )')
/*
<People NAME="周星驰" />
*/
SELECT @x = '
<Peoples>
<People NAME="周星驰"/>
<People NAME="刘德华"/>
<People NAME="周杰伦"/>
</Peoples>'
SELECT @X.query('(/Peoples) ')
/*
<Peoples>
<People NAME="周星驰" />
<People NAME="刘德华" />
<People NAME="周杰伦" />
</Peoples>
*/
SELECT @X.query('(/Peoples/People[last()]) ')
/*
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People[.]) ')
/*
<People NAME="周星驰" />
<People NAME="刘德华" />
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People[. >> (/Peoples/People[@NAME="周星驰"])[1]]) [last()] ')
/*
<People NAME="周杰伦" />
*/
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[last()]] )')
/*
<People NAME="周星驰" />
*/
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[1]] )')
/*
<People NAME="周星驰" />
*/
SELECT @X.query('( . is .)')
SELECT @X.query('(/Peoples/People [. is (/Peoples/People[@NAME="周星驰"])[1]] )')
/*
<People NAME="周星驰" />
*/