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

SQL ServerÖ®·Ö²¼Ê½ÊÂÎñ

--> Title  : SQL ServerÖ®·Ö²¼Ê½ÊÂÎñ
--> Author : wufeng4552
--> Date   : 2009-11-11
SQL ServerÖ®·Ö²¼Ê½ÊÂÎñ
(Ò»)¸ÅÄî:
·Ö²¼Ê½ÊÂÎñÊÇÉæ¼°À´×ÔÁ½¸ö»ò¶à¸öÔ´µÄ×ÊÔ´µÄÊÂÎñ¡£Microsoft® SQL Server™ 2000Ö§³Ö·Ö²¼Ê½ÊÂÎñ£¬Ê¹Óû§µÃÒÔ´´½¨ÊÂÎñÀ´¸üжà¸öSQL ServerÊý¾Ý¿âºÍÆäËüÊý¾ÝÔ´¡£
·Ö²¼Ê½ÊÂÎñ°üÀ¨£º
·×ÊÔ´¹ÜÀíÆ÷
¿ØÖÆ·Ö²¼Ê½ÊÂÎñËùÉæ¼°µÄÿ¸ö×ÊÔ´µÄÈí¼þ³ÆΪ×ÊÔ´¹ÜÀíÆ÷¡£·Ö²¼Ê½ÊÂÎñÓɸ÷¸ö×ÊÔ´¹ÜÀíÆ÷Äڵı¾µØÊÂÎñ×é³É¡£Ã¿¸ö×ÊÔ´¹ÜÀíÆ÷±ØÐëÄܹ»Óë·Ö²¼Ê½ÊÂÎñÄÚµÄËùÓÐÆäËü×ÊÔ´¹ÜÀíÆ÷ÏàЭµ÷£¬ÒÔÌá½»»ò»Ø¹ö×Ô¼ºµÄ±¾µØÊÂÎñ¡£SQL Server ¿ÉÒÔ×÷Ϊ·Ö²¼Ê½ÊÂÎñÄÚµÄ×ÊÔ´¹ÜÀíÆ÷¹¤×÷£¬²¢×ñ´ÓÓÃÓÚ·Ö²¼Ê½ÊÂÎñ´¦ÀíµÄ X/Open XA ¹æ·¶¡£
·ÊÂÎñ¹ÜÀíÆ÷
Ìá½»»ò»Ø¹ö·Ö²¼Ê½ÊÂÎñÓɳÆΪÊÂÎñ¹ÜÀíÆ÷µÄÈí¼þ×é¼þ¿ØÖÆ¡£ÊÂÎñ¹ÜÀíÆ÷Óëÿ¸ö×ÊÔ´¹ÜÀíÆ÷ÏàЭµ÷£¬È·±£Ò»ÆðÌá½»»ò»Ø¹öËùÓÐ×é³É·Ö²¼Ê½ÊÂÎñµÄ±¾µØÊÂÎñ¡£Microsoft·Ö²¼Ê½ÊÂÎñ´¦ÀíЭµ÷Æ÷ (MS DTC) ·þÎñÈçÊÂÎñ¹ÜÀíÆ÷Ò»Ñù¹¤×÷¡£MS DTC ×ñ´ÓÓÃÓÚ·Ö²¼Ê½ÊÂÎñ´¦ÀíµÄ X/Open XA ¹æ·¶¡£
·Á½½×¶ÎÌá½» (2PC)
ÐèÒª½øÐÐÌØÊâµÄÌá½»´¦Àí£¬ÒÔ·ÀÖ¹ÔÚ¹ÜÀí¿çÔ½¶à¸ö×ÊÔ´¹ÜÀíÆ÷µÄÊÂÎñʱ³öÏÖÎÊÌâ¡£µ±Ë¢ÐÂÈÕÖ¾»º³åÇøʹÆä¿ÉÓÃʱ£¬Ìá½»´óÊÂÎñ¿ÉÄÜÐèÒªÏà¶Ô½Ï³¤µÄʱ¼ä¡£Ìá½»½ø³Ì±¾Éí»¹¿ÉÄÜÓöµ½´íÎó£¬ÐèҪǿÐлعö¡£Èç¹ûÊÂÎñ¹ÜÀíÆ÷Ö»ÊÇÇëÇóÿ¸ö×ÊÔ´¹ÜÀíÆ÷Ìá½»£¬Ôò¿ÉÄÜ´ÓһЩ×ÊÔ´¹ÜÀíÆ÷·µ»Ø³É¹¦×´Ì¬£¬È»ºó´Óij¸ö×ÊÔ´¹ÜÀíÆ÷µÃµ½´íÎóÐÅÏ¢¡£Õâ»áµ¼Ö³åÍ»£¬ÒòΪËùÓзֲ¼Ê½ÊÂÎñ¶¼Ó¦»Ø¹ö£¬¶ø²¿·ÖÊÂÎñÒÑÌá½»¡£Á½½×¶ÎÌύͨ¹ý½«Ìá½»·Ö³ÉÁ½Ïà¿ÉÒÔ½â¾ö´ËÎÊÌ⣺
·×¼±¸
ÊÂÎñ¹ÜÀíÆ÷¸øÿ¸ö×ÊÔ´¹ÜÀíÆ÷·¢ËÍÒ»¸ö×¼±¸Ìá½»µÄÇëÇó¡£È»ºó£¬Ã¿¸ö×ÊÔ´¹ÜÀíÆ÷Ö´ÐÐÍê³ÉÌá½»½ø³ÌËùÐèµÄËùÓдóÁ¿Õ¼ÓÃ×ÊÔ´µÄ²Ù×÷£¬ÈçË¢ÐÂËùÓÐÈÕÖ¾»º³åÇø¡£×ÊÔ´¹ÜÀíÆ÷Ö»±£Áôά»¤ÊÂÎñÍêÕûÐÔËùÐèµÄ×îÉÙµÄËø£¬È»ºó¸øÊÂÎñ¹ÜÀíÆ÷·µ»Ø³É¹¦×´Ì¬¡£
·Ìá½»
Èç¹ûËùÓÐ×ÊÔ´¹ÜÀí¶Ô·¢¸øËüÃǵÄ×¼±¸ÇëÇ󷵻سɹ¦×´Ì¬£¬ÊÂÎñ¹ÜÀíÆ÷½«¸øÿ¸ö×ÊÔ´¹ÜÀíÆ÷·¢ËÍÌá½»ÃüÁȻºó£¬Ã¿¸ö×ÊÔ´¹ÜÀíÆ÷¿ìËÙ½«ÊÂÎñ¼Ç¼ΪÒÑÍê³É£¬²¢ÊÍ·ÅÉϴοØÖƵÄ×ÊÔ´¡£Èç¹ûÓÐÈκÎ×ÊÔ´¹ÜÀíÆ÷¶Ô×¼±¸ÇëÇ󷵻شíÎóÐÅÏ¢£¬ÊÂÎñ¹ÜÀíÆ÷½«¸øÿ¸ö×ÊÔ´¹ÜÀíÆ÷·¢ËͻعöÃüÁî¡£
Óм¸ÖÖ·½·¨¿ÉÒÔʹӦÓóÌÐòÔÚ·Ö²¼Ê½ÊÂÎñÄÚ°üÀ¨ SQL Server 2000£º
·Èç¹ûÓ¦ÓóÌÐòÓб¾µØÊÂÎñ²¢ÇÒ·¢³ö·Ö²¼Ê½²éѯ£¬±¾µØÊÂÎñ½«Éý¼¶µ½·Ö²¼Ê½ÊÂÎñ¡£
··¢³ö BEGIN DISTRIBUTED TRANSACTION Ó


Ïà¹ØÎĵµ£º

PowerShell±Ê¼Ç£¨Èý£©£ºµ÷ÓÃMS SQLÊý¾Ý¿â

ÊÔÁËÒ»°ÑPowerShell·ÃÎÊÊý¾Ý¿â£¬¸úÓÃC#д¼¸ºõûÈκÎÇø±ð~
ΪÁ˼òµ¥Æð¼û£¬´úÂëÓеã³ó£¬²»ÓÃÌ«É
$ConnString = "server=_SERVER_;database=_DATABASE_;user id=_UID_;password=_PWD_";
$db = New-Object System.Data.SqlClient.SqlConnection($ConnString);
$db.Open();
$Sql = "select top 10 * from sys.objects wh ......

SQL UnionÓ÷¨×ܽá

UNION ÔËËã·û½«¶à¸ö SELECT Óï¾äµÄ½á¹û×éºÏ³ÉÒ»¸ö½á¹û¼¯¡£ £¨£±£©Ê¹Óà UNION ÐëÂú×ãÒÔÏÂÌõ¼þ£º £Á£ºËùÓвéѯÖбØÐë¾ßÓÐÏàͬµÄ½á¹¹£¨¼´²éѯÖеĵÄÁÐÊýºÍÁеÄ˳Ðò±ØÐëÏàͬ£©¡£ £Â£º¶ÔÓ¦ÁеÄÊý¾ÝÀàÐÍ¿ÉÒÔ²»Í¬µ«ÊDZØÐë¼æÈÝ£¨ËùνµÄ¼æÈÝÊÇÖ¸Á½ÖÖÀàÐÍÖ®¼ä¿ÉÒÔ½øÐÐÒþʽת»»£¬²»ÄܽøÐÐÒþʽת»»Ôò±¨´í£©¡£Ò²¿ÉÒÔÓÃÏÔʽת»»ÎªÏàͬµ ......

¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨


SQL code
¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
eg: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
eg:
declare @ ......

javaÓëSQLÊý¾Ý¿âÇŽӷ½Ê½Ò×´íÎÊÌâÓëÉè¼ÆºËÐÄ

 ÎÄÕÂÔ­´´£¬×ªÔØÇëÓëBlogÖ÷ÈËÁªÏµ£¬robin9257@hotmail.com
JAVAÓëSQLÇŽӵÄÓÅȱµã£º
1¡¢Óŵ㣺²»ÓÃÏÂÔØÇý¶¯³ÌÐò£¬ÔÊÐíÓÃÏàͬ´úÂë·ÃÎʲ»Í¬DBMS¡£
2¡¢È±µã£ºÐ§Âʵ͡£
¾­³£³öÏֵı¨´íµã£º
1¡¢java.sql.SQLException: [Microsoft][ODBC Çý¶¯³ÌÐò¹ÜÀíÆ÷] δ·¢ÏÖÊý¾ÝÔ´Ãû³Æ²¢ÇÒδָ¶¨Ä¬ÈÏÇý¶¯³ÌÐò
  
&nbs ......

¹ØÓÚSQLÓï¾äµÄ×Ô¶¯Éú³É

ÔÚÎÒÃǵÄÈÕ³£±à³ÌÖУ¬Êý¾Ý¿âµÄ³ÌÐò»ù±¾É϶¼ÒªÓëSQLÓï¾ä´ò½»µÀ£¬SQLÓï¾äµÄ±àд²»¿É±ÜÃâµÄ³ÉΪһ¸öÍ·Ì۵Ť×÷¡£ÇÒÒòΪSQLÓï¾äÊÇSTRINGÀàÐÍ£¬Òò´ËÔÚ±àÒë½×¶Î²é²»³ö´í£¬Ö»Óе½ÔËÐÐʱ²ÅÄÜ·¢ÏÖ´íÎó¡£
±¾ÎĵĽâ¾ö·½°¸£¬Í¨¹ý×Ô¶¯Éú³ÉSQLÓï¾ä£¬ÔÚÒ»¶¨³Ì¶ÈÉϽµµÍ³ö´íµÄ¸ÅÂÊ£¬´Ó¶øÌá¸ß±à³ÌЧÂÊ¡£     public int ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ