SQL XML DELETE
--A. ´Ó´æ´¢ÔÚ·ÇÀàÐÍ»¯µÄ xml ±äÁ¿ÖеÄÎĵµÖÐɾ³ý½Úµã
DECLARE @myDoc xml
SET @myDoc = '<?Instructions for=TheWC.exe ?>
<Root>
<!-- instructions for the 1st work center -->
<Location LocationID="10" LaborHours="1.1" MachineHours=".2" >
Some text 1
<step>Manufacturing step 1 at this work center</step>
<step>Manufacturing step 2 at this work center</step>
</Location>
</Root>'
SELECT @myDoc
-- delete an attribute
SET @myDoc.modify('
delete /Root/Location/@MachineHours
')
SELECT @myDoc
-- delete an element
SET @myDoc.modify('
delete /Root/Location/step[2]
')
SELECT @myDoc
-- delete text node (in <Location>
SET @myDoc.modify('
delete /Root/Location/text()
')
SELECT @myDoc
-- delete all processing instructions
SET @myDoc.modify('
delete //processing-instruction()
')
SELECT @myDoc
--B. ´Ó´æ´¢ÔÚ·ÇÀàÐÍ»¯µÄ xml ÁÐÖеÄÎĵµÖÐɾ³ý½Úµã
delete XML DML Óï¾ä´Ó´æ´¢ÔÚÁÐÖеÄÎĵµÖÐɾ³ý <Features> µÄµÚ¶þ¸ö×ÓÔªËØ¡£
CREATE TABLE #T (i int, x xml)
go
INSERT INTO #T VALUES(1,'<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features>
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
</Features>
</ProductDescription>
</Root>')
go
-- verify the contents before delete£¬query·µ»ØFeaturesÔªËØϵÄËùÓнڵã,ÒÔXML¸ñʽ·µ»Ø
SELECT x.query('//ProductDescription/Features')
from #T
-- delete the second feature
UPDATE #T
SET x.modify('delete /Root/ProductDescription/Features/*[2]')
-- verify the deletion
SELECT x.query(' //ProductDescription/Features')
from #T
DROP TABLE #T
C. ´Ó·ÇÀàÐÍ»¯µÄ xml ÁÐÖÐɾ³ý½Úµã
create table #T(ProductModelID int primary key,
Instructions xml )
go
insert #T
select ProductModelID, Instructions
from Prod
Ïà¹ØÎĵµ£º
@@IDENTITY£º·µ»Ø×îºó²åÈëµÄ±êʶֵµÄϵͳº¯Êý¡£
SCOPE_IDENTITY£º·µ»Ø²åÈ뵽ͬһ×÷ÓÃÓòÖеıêʶÁÐÄÚµÄ×îºóÒ»¸ö±êʶֵ¡£Ò»¸ö·¶Î§ÊÇÒ»¸öÄ£¿é£º´æ´¢¹ý³Ì¡¢´¥·¢Æ÷¡¢º¯Êý»òÅú´¦Àí¡£Òò´Ë£¬Èç¹ûÁ½¸öÓï¾ä´¦ÓÚͬһ¸ö´æ´¢¹ý³Ì¡¢º¯Êý»òÅú´¦ÀíÖУ¬ÔòËüÃÇλÓÚÏàͬµÄ×÷ÓÃÓòÖС£
IDENT_CURRENT:·µ»ØΪָ¶¨µÄ±í»òÊÓͼÉú³ÉµÄ×îºóÒ»¸ö±êʶֵ ......
×î½üÔÚ×öNetConfÏà¹Ø¿ª·¢¹¤×÷£¬ÆäÖкÜÖØÒªµÄÒ»¿éÊÇXML½âÎö£¬ÏîÄ¿Ò²ÐèÒªÖ§³ÖSchema£¬Òò´ËÇ°¶Îʱ¼äÕûÀíÁËSchemaµÄÁ½²¿·Ö±ê×¼£¬Ö»²»¹ýÕûÀíÎĵµÊÇÎÞ·¨´ø³öÀ´µÄ£¬ËùÒÔ¾ÍÔÚ´Ë°ÑSchemaÏà¹ØµÄÄÚÈݼòµ¥½éÉÜÆä±ê×¼Ö®ºó£¬ÒÔÈçºÎÓ¦Óõķ½Ê½¼Ç¼ÏÂÀ´£¬ÒÔ¹©ÒÔºóʹÓÃʱ²Î¿¼¡£ÔÚºóÐøµÄ²¿·Ö£¬ÎÒ» ......
°ÑxmlÍϵ½IEÀï¾ÍÕÒµ½´íÔÚÄÄÀïÁË
ÈçÏ£º
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
ÎĵµµÄ¶¥²ãÎÞЧ¡£´¦Àí×ÊÔ´ 'file:///D:/Tomcat 5.5/webapps/myapp/WEB-INF/web.xml' ʱ³ö´í¡£µÚ 1 ÐУ¬Î»ÖÃ: 44 ......
http://blog.csdn.net/java2000_net/archive/2008/04/05/2252640.aspx
http://sqlserver.chinahtml.com/2006/SQL-mssql11432786154012.shtml
http://www.cnblogs.com/garnai/archive/2007/09/19/898221.html
http://tech.ccidnet.com/art/1099/20050223/214511_1.html
http://www.wangchao.net.cn/bbsdetail_43009.html ......