18¾ä»°ÈëÃÅSQLServer XML
18¾ä»°ÈëÃÅSQLServer XML ÊÕ²Ø
/*
sql xml ÈëÃÅ:
--by jinjazz
--http://blog.csdn.net/jinjazz
1¡¢xml: ÄÜÈÏÊ¶ÔªËØ¡¢ÊôÐÔºÍÖµ
2¡¢xpath: ѰַÓïÑÔ£¬ÀàËÆwindowsĿ¼µÄ²éÕÒ(ûÓùýdirÃüÁîµÄ»°¾ÍÈ¥Ãæ±Ú)
Óï·¨¸ñʽ£¬ÕâЩÓï·¨¿ÉÒÔ×éºÏΪÌõ¼þ£º
"."±íʾ×Ô¼º£¬".."±íʾ¸¸Ç×£¬"/"±íʾ¶ù×Ó£¬"//"±íʾºó´ú£¬
"name"±íʾ°´Ãû×Ö²éÕÒ£¬"@name"±íʾ°´ÊôÐÔ²éÕÒ
"¼¯ºÏ[Ìõ¼þ]" ±íʾ¸ù¾ÝÌõ¼þÈ¡¼¯ºÏµÄ×Ó¼¯£¬Ìõ¼þ¿ÉÒÔÊÇ
Êý Öµ£ºÊý×Ö,last(),last()-Êý×Ö µÈ
²¼¶ûÖµ£ºposition()<Êý×Ö,@name='Ìõ¼þ',name='Ìõ¼þ'
Ìõ¼þÊDz¼¶ûÖµµÄʱºò¿ÉÒԺϲ¢¼ÆË㣺and or
3¡¢xquery: »ùÓÚxpath±êµÄ×¼²éѯÓïÑÔ£¬sqlserver xquery°üº¬ÈçϺ¯Êý
exist(xpathÌõ¼þ)£º·µ»Ø²¼¶ûÖµ±íʾ½ÚµãÊÇ·ñ´æÔÚ
query(xpathÌõ¼þ)£º·µ»ØÓÉ·ûºÏÌõ¼þµÄ½Úµã×é³ÉµÄеÄxmlÎĵµ
&n
Ïà¹ØÎĵµ£º
sqlserver2005Óйؼü×Öntile(x)ºÍover(partition by.. order by..)×Ó¾äÅäºÏ.
±ÈÈç»ñȡÿ¸ö±íµÄǰ10%¸ö×ֶΡ£
select id , name , colid , rn from (
select * , rn = ntile (10 )
over (partition by id order by colorder )
from syscolumns )t where rn = 1 ......
SQLServerÖÐÓÐÁ½¸öÀ©Õ¹´æ´¢¹ý³ÌʵÏÖScanfºÍPrintf¹¦ÄÜ£¬Ç¡µ±µÄʹÓÃËüÃÇ¿ÉÒÔÔÚÌáÈ¡ºÍÆ´½Ó×Ö·û´®Ê±´ó·ù¶È¼ò»¯SQL´úÂë¡£
1¡¢xp_sscanf£¬ÓÃËü¿ÉÒÔ·Ö½â¸ñʽÏà¶Ô¹Ì¶¨µÄ×Ö·û´®£¬Õâ¶ÔÓÚÑá¾ëʹÓÃÒ»¶ÑsubstringºÍcharindexµÄÅóÓÑÀ´Ëµ²»´í¡£±ÈÈçǰ¼¸ÌìµÄÒ»¸öÌû×ÓÖÐÌá³öµÄÈçºÎ·Ö½âipµØÖ·£¬Ïà¶Ô¼òÁ·ÇÒͨÓõĴúÂëÓ¦¸ÃÊÇÏÂÃæÕâÑù
------- ......
Declare @Id int
Declare @Name varchar(20)
Declare Cur Cursor For Select Id,Name from T_User
Open Cur
Fetch next from Cur Into @Id,@Name
While @@fetch_status=0
Begin
Update T_User Set [Name]=@Name,Id=@Id
......
HOLDLOCK ½«¹²ÏíËø±£Áôµ½ÊÂÎñÍê³É£¬¶ø²»ÊÇÔÚÏàÓ¦µÄ±í¡¢ÐлòÊý¾ÝÒ³²»ÔÙÐèҪʱ¾ÍÁ¢¼´ÊÍ·ÅËø¡£HOLDLOCK µÈͬÓÚ SERIALIZABLE¡£
NOLOCK ²»Òª·¢³ö¹²ÏíËø£¬²¢ÇÒ²»ÒªÌṩÅÅËüËø¡£µ±´ËÑ¡ÏîÉúЧʱ£¬¿ÉÄÜ»á¶ÁȡδÌá½»µÄÊÂÎñ»òÒ»×éÔÚ¶ÁÈ¡ÖÐ¼ä»Ø¹öµÄÒ³Ãæ¡£ÓпÉÄÜ·¢ÉúÔà¶Á¡£½öÓ¦ÓÃÓÚ SELECT Óï¾ä¡£
PAGLOCK ÔÚͨ³£Ê¹Óõ¥¸ö±íËøµ ......