Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL Server2005µÄXMLÊý¾ÝÀàÐÍÖ®»ù´¡Æª2

value·½·¨
µ±Äã²»Ïë½âÊÍÕû¸ö²éѯµÄ½á¹û¶øÖ»ÏëµÃµ½Ò»¸ö±êÁ¿ÖµÊ±£¬Õâ¸övalue·½·¨ÊǺÜÓаïÖúµÄ¡£Õâ¸övalue·½·¨ÓÃÓÚ²éѯXML²¢ÇÒ·µ»ØÒ»¸öÔ­×ÓÖµ¡£
Õâ¸övalue·½·¨µÄÓï·¨ÈçÏ£º
value(XQuery£¬datatype)
½èÖúÓÚvalue·½·¨£¬Äã¿ÉÒÔ´ÓXMLÖеõ½µ¥¸ö±êÁ¿Öµ¡£Îª´Ë£¬Äã±ØÐëÖ¸¶¨XQueryÓï¾äºÍÄãÏëÒªËü·µ»ØµÄÊý¾ÝÀàÐÍ£¬²¢ÇÒÄã¿ÉÒÔ·µ»Ø³ýÁËXMLÊý
¾ÝÀàÐÍÍâµÄÈκÎÊý¾ÝÀàÐÍ¡£ÀýÈ磬Èç¹ûÄãÏëµÃµ½Ã¿Ò»¸öС×éÖеĵÚÒ»¸öͶÇòÊÖµÄÃû×Ö£¬Äã¿ÉÒÔ±àдÈçÏÂÐÎʽµÄ²éѯÓï¾ä£º
½øÐÐÒ»´Î²éѯÒԵõ½µ¥¸öÖµ
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SELECT TeamDoc.value(
'(/Team/Players/Pitcher/@name)[1]'£¬
'nvarchar(max)')
AS FirstPitcher
from Team
ÔÚÿһ¸öС×éµÄµÚÒ»¸öͶÇòÊֵıêÁ¿ÖµÖеÄÕâ¸ö²éѯ½á¹û·µ»ØÖµÈçÏ£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
FirstPitcher
------------------------------
John Smoltz
(1 row(s) affected)
×¢Ò⣬queryºÍvalue·½·¨Ö®¼äµÄ²»Í¬ÔÚÓÚ£¬query·½·¨·µ»ØÒ»¸öXMLÊý¾ÝÀàÐÍ-Ëü°üº¬²éѯµÄ½á¹û£»¶øvalue·½·¨·µ»ØÒ»¸ö´øÓвéѯ½á¹ûµÄ·Ç
XMLÊý¾ÝÀàÐÍ¡£ÁíÍ⣬value·½·¨½öÄÜ·µ»Øµ¥¸öÖµ(»ò±êÁ¿Öµ)¡£Èç¹ûÄãÊÔͼ´´½¨Ò»¸öʹÓÃvalue·½·¨·µ»Ø¶àÓÚÒ»¸öÖµµÄXQuery±í´ïʽ£¬Ä㽫µÃµ½Ò»
¸ö´íÎó¡£
modify·½·¨
¾¡¹ÜXQuery±ê×¼²¢Ã»ÓÐÌṩһÖÖ¸üÐÂXMLµÄ»úÖÆ£¬µ«ÊÇSQL Server 2005ÌṩÁËÒ»ÖÖ·½·¨ÓÃÓÚ¼´Ê±µØÐÞ¸ÄÒ»¸öXML¶ÔÏóµÄÒ»²¿·Ö¡£ÕâÒâζ×Å£¬
Äã²»±Ø½öΪÁËÐ޸Ķø¼ìË÷Ò»¸öÍêÕûµÄXMLÎĵµ¡£ÎªÁ˼´Ê±ÐÞ¸ÄÒ»¸öÎĵµ£¬Äã¿ÉÒÔ²ÉÓÃÒ»ÖÖ½áºÏ·½Ê½-Modify·½·¨ºÍSQL Server 2005µÄеÄXMLÊý
¾ÝÐÞ¸ÄÓïÑÔ(XML DML)¡£
Modify·½·¨µÄÓï·¨ÊÇ£º
modify(£¼XMLDML£¾)
¸Ã·½·¨½öʹÓÃÒ»¸ö²ÎÊý£ºXML DMLÓï¾ä¡£XML DMLÒ²ÀàËÆÓÚSQLµÄinsert£¬updateºÍdeleteÓï·¨£¬µ«ÊDz¢²»Ò»Ñù¡£ÀýÈ磬Äã¿ÉÒÔͨ¹ýʹÓÃ
insert DMLÓï¾äÀ´ÐÞ¸ÄXML£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
SET @doc.modify('
insert £¼Pitcher name="Jaret Wright"/£¾ as last
into (/Team/Players)[1]
')
ÁíÍ⣬Ä㻹¿ÉÒÔͨ¹ýµ÷ÓÃÒ»¸öUPDATEÓï¾ä²¢ÐÞ¸ÄÒ»¸öXMLÁÐÀ´ÊµÏÖͬÑùÄ¿µÄ£º
ÐÞ¸ÄÒ»¸öXMLÎĵµ¶ø²»ÍêÈ«Ìæ»»Ëü£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
UPDATE Team
SET TeamDoc.modify('
insert £¼Pitcher name="Jaret Wright"/£¾ as last
into (/Team/Players)[1]
')
WHERE TeamDoc.exist('/Team[@name="Braves"]') = 1 
×¢Ò⣬ÔÚÕâ¸öUPDATEÓï¾äÖеÄSET×Ӿ䲢²»×ñÑ­Äã¹ýÈ¥±àдSQLʱËùʹÓõÄSET x = y ģʽ¡£¸ÃÓï·¨¼Ù¶¨£¬ÄãÄܹ»Ìṩһ¸öÍêȫеÄÖµÀ´´ú


Ïà¹ØÎĵµ£º

SQLµ÷Õû×î¹Ø×¢µÄÊÇʲô£¿

µ÷ÕûµÄÄ¿µÄ¾ÍÊÇΪÁËÏûºÄ×îСµÄ×ÊÔ´À´Íê³É¹¦ÄÜ£¬Í¨¹ý²é¿´Ö´Ðмƻ®ºÍ¸÷ÖÖͳ¼ÆÐÅÏ¢À´·Ö±æµ÷ÕûºóµÄsql¶Ô×ÊÔ´µÄºÄ·ÑÇé¿ö£¬À´ÕÒ³öÒ»¸ö³É±¾×îСµÄsqlÓï¾ä
¼ì²éϵͳµÄI/OÎÊÌâ
vmstateÄܼì²éÕû¸öϵͳµÄiostat£¨IO statistics£©
²é¿´¸ÃSQLµÄresponse time(db block gets/consistent gets/physical reads/sorts (disk)) ......

SQL ServerÊÓͼÖг£見ÏÞÖÆÌõ¼þ

--> Title  : SQL ServerÊÓͼÖг£見ÏÞÖÆÌõ¼þ
--> Author : wufeng4552
--> Date   : 2010-03-01
(1): ÊÓͼÊý¾Ý¸ü¸ÄµÄ³£見ÏÞ¶¨
µ±Óû§¸üÐÂÊÓͼÖеÄÊý¾Ýʱ,Æäʵ¸ü¸ÄµÄÊÇÆä¶ÔÓ¦µÄÊý¾Ý±íµÄÊý¾Ý.ÎÞÂÛÊǶÔÊÓͼÖеÄÊý¾Ý½øÐиü¸Ä,»¹ÊÇÔÚÊÓͼÖвåÈë»òÕßɾ³ýÊý¾Ý,¶¼ÊÇÀàËƵĵÀÀí.µ«ÊÇ,² ......

SQL Convert ʱ¼ä½ØÈ¡£¨×ª»¯£©Ñùʽ

ÄÚÈÝת×Ô£ºhttp://blog.csdn.net/lfzwenzhu/archive/2008/03/06/2153473.aspx
SELECT CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
SELECT CONVERT(varchar(100), GETDATE(), 1): 05/16/06
SELECT CONVERT(varchar(100), GETDATE(), 2): 06.05.16
SELECT CONVERT(varchar(100), GETDATE(), 3): 16/05/06
......

ÈçºÎÔÚδ¼ÓÈëÓòµÄ»úÆ÷ÉÏʹÓü¯³ÉÈÏÖ¤À´µÇ½SQL Server

Ò»°ãʹÓÃSQL ServerµÄ¼¯³ÉÈÏ֤ʱ£¬¶¼ÐèÒªµÇ½½øÓò£¬ÏÂÃæ½éÉÜÒ»ÖÖ²»ÐèÒªµÇ½Óò¾Í¿ÉÒÔʹÓÃÓòÓû§µÇ½SQL ServerµÄ·½·¨¡£
SQL Server Management Studio 2005ºÍ2008µÄ¿ì½Ý·½Ê½ÈçÏÂͼ£º
  
SQL Server 2008 x64: "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
SQL ......

SQL Server 2005Éý¼¶µÄ10¸öÀíÓÉ

SQL Server 2005Éý¼¶µÄ10¸öÀíÓÉ
¡¡ºÜ¶àÈ˹ØÐĵĺ͵£ÐĵĶ¼ÊÇ SQL Server 2005 Ïà¶ÔËüµÄÇ°°æ±¾SQL Server 2000Ëù×öµÄÖØ´ó¸Ä½ø»òÐÂÔö¹¦ÄÜ¡£ÔÚÎÒÉý¼¶µ½SQL2005Ö®ºó£¬²»µÃ²»ËµµÄ£ºÄãÒ²ÖµµÃÓµÓС£(Ì×ÓÃÒ»¾ä¹ã¸æÓºÇºÇ)
¡¡¡¡ÎÒ×ܽáÁËһϸöÈËÈÏΪSQL Server 2005 ÖÐ×îÖµµÃÄãΪ֮Éý¼¶µÄ10 ¸öÀíÓÉ¡£ÎÞÂÛÄãÊÇÏëÁ˽â»òѧϰSQL Se ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ