Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ģʽ¡£¸ÃÓï·¨¼Ù¶¨£¬ÄãÄܹ»Ìṩһ¸öÍêȫеÄÖµÀ´´ú


Ïà¹ØÎĵµ£º

Vistual Studio XML ÖÇÄÜÌáʾ

      ¿ª·¢Öо­³£Óöµ½ÒªºÍ¸÷ÖÖ¸÷ÑùµÄ XML ´ò½»µÀ£¬±à¼­ XML Îļþʱ×îÍ·Í´µÄ±ãÊÇÒª¼ÇסÐí¶à XML ÔªËØÃû³Æ¡¢ÊôÐÔÃû³Æ¡£
      ÐÒÔ˵ÄÊÇ£¬Vistual Studio µÄ XML ÖÇÄÜÌáʾ¹¦ÄÜ¿ÉÒÔ´ó´óµØ¼õÇáÕâһʹ¿à¡£Ö»Ðèͨ¹ýÌí¼Ó×Ô¶¨ÒåµÄ XSD ÎļþʹµÃÔڱ༭ XML Îļþʱ»ñµÃV ......

PowerDesignerÉú³ÉSQL ERͼ ˵Ã÷Îĵµ

Ò»¡¢PowerDesignerÉú³ÉsqlÎÊÌâ
Éú³ÉsqlµÄ·½·¨ÊÇ Database -->Generate Database (Ctrl + G ) µ«ÊÇÌáʾ Could not load VBScript engine.
Check VBScript installation. Generation aborted due to errors detected during the verification of the model. ¼ì²éÁ˺þà ·¢ÏÖ½«check model È¥µô¾Í¿ÉÒÔÁË£¡ÆäÖУ¬ o ......

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 ÓαêµÄ»ù±¾Ó÷¨

1. ¶¨ÒåÓα궨Òå
ÓαêÓï¾äµÄºËÐÄÊǶ¨ÒåÁËÒ»¸öÓαê±êʶÃû£¬²¢°ÑÓαê±êʶÃûºÍÒ»¸ö²éѯÓï¾ä¹ØÁªÆðÀ´¡£DECLAREÓï¾äÓÃÓÚÉùÃ÷Óα꣬Ëüͨ¹ýSELECT²éѯ¶¨ÒåÓαê´æ´¢µÄÊý¾Ý¼¯ºÏ¡£Óï¾ä¸ñʽΪ£º
DECLARE ÓαêÃû³Æ [INSENSITIVE] [SCROLL]
CURSOR FOR selectÓï¾ä
[FOR{READ ONLY|UPDATE[OF ÁÐÃû×Ö±í]}]
²ÎÊý˵Ã÷£º
INSENSITIVEÑ¡Ï ......

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

Ò»¡¢ÒýÑÔ
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬XML³ÉΪµÚÒ»Á÷µÄÊý¾ÝÀàÐÍ¡£½èÖúÓÚ»ùÓÚXMLģʽµÄÇ¿ÀàÐÍ»¯Ö§³ÖºÍ»ùÓÚ·þÎñÆ÷¶ËµÄXMLÊý¾ÝУÑ鹦ÄÜ£¬ÏÖÔÚ
£¬¿ª·¢Õß¿ÉÒÔ¶Ô´æ´¢µÄXMLÎĵµ½øÐÐÇáËɵØÔ¶³ÌÐ޸ġ£×÷ΪÊý¾Ý¿â¿ª·¢Õߣ¬Ðí¶àÈ˶¼±ØÐë´óÁ¿µØÉæ¼°XML¡£
Èç½ñ£¬ÔÚSQL Server 2005ÖУ¬ÄãÄÜÒÔÒ»ÖÖеÄÊý¾ÝÀàÐ͵ÄÐÎʽ°ÑXML´æ´¢ÔÚÊý¾Ý¿âÖÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ