[已解决问题]
解决于 2008-01-24 09:53
<P>alter procedure prc_test<BR>( <BR> @ID nvarchar(50)<BR>)<BR>as<BR>DECLARE @tmpXML AS XML<BR>SET @tmpXML = '<BR><Categories><BR> <CategoryInfo CategoryID ="1"><BR> <CategoryName>Beverages</CategoryName> <BR> <Description>Soft drinks, coffees, teas, beers, and ales</Description> <BR> </CategoryInfo><BR> <CategoryInfo CategoryID ="2"><BR> <CategoryName>Condiments</CategoryName><BR> <Description>Sweet and savory sauces, relishes, spreads, and seasonings</Description> <BR> </CategoryInfo><BR> <CategoryInfo CategoryID ="3"><BR> <CategoryName>Confections</CategoryName> <BR> <Description>Desserts, candies, and sweet breads</Description> <BR> </CategoryInfo><BR> <CategoryInfo CategoryID ="4"><BR> <CategoryName>Dairy Products</CategoryName> <BR> <Description>Cheeses</Description> <BR> </CategoryInfo><BR></Categories><BR>'</P>
<P>SELECT @tmpXML.query('<BR>for $var in /Categories/CategoryInfo<BR>where $var <A>/@CategoryID</A> ="<A href="mailto:'+@ID+'">'+@ID+'</A>"<BR>return ($var)') AS test<BR>GO<BR>--exec prc_test 2</P>
<P>我要按参数<U><FONT color=#006600>@ID</FONT></U>查询 @CategoryID,这里应该怎么写?<BR>where $var <A>/@CategoryID</A> ="<A href="mailto:'+@ID+'">'+@ID+'</A>"<BR></P>
<P mce_keep="true"> </P>