SQL SERVER´æ´¢¹ý³ÌÖÐʹÓÃÊÂÎñ
Create PROCEDURE UpdateWanjun
@UserName nvarchar(500),
@UserPassword nvarchar(500),
@ReturnVal int output
AS
--Set XAcT_ABORT ON
Begin Transaction T
Update admins set UserPassword = @UserPassword where UserName = @UserName
Update admins set UserPassword = @UserPassword,a='aaadfasdfasdfas' where id=4 --³ö´íÓï¾ä ,aΪintÐÍ,´óСΪĬÈÏÖµ4
--set @ReturnVal=@@Rowcount(Õâ¸ö±äÁ¿,Ö»ÄÜÔÚ½ô°¤×ÅËüµÄÉÏÃæSQLÏÂÆð×÷ÓÃ,ÕâÑù²ÅÄÜ·µ»ØÖµ,Ö»ÓзÅÔÚUpdateÏÂÃæ²Å¹ÜÓÃ)
IF @@Error <> 0
Begin
Print '111'
RollBack Transaction T
End
Else
print '222'
COMMIT Transaction T
GO
####################################################################################
Èç¹ûÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÖ´Ðе÷ÓÃÁíÒ»¸ö·þÎñÆ÷ÉϵĴ洢¹ý³Ìʱ£¬Ìí¼ÓÊÂÎñʱÐèҪʹÓÃ
BEGIN DISTRIBUTED TRANSACTIONÀ´¿ªÊ¼ÊÂÎñ£¨·Ö²¼Ê½ÊÂÎñ£©
BEGIN DISTRIBUTED TRAN [ SACTION ]
[ transaction_name
| @tran_name_variable
]
²ÎÊý
transaction_name
ÊÇÓû§¶¨ÒåµÄÊÂÎñÃû£¬ÓÃÓÚ¸ú×Ù MS DTC ʵÓù¤¾ßÖеķֲ¼Ê½ÊÂÎñ¡£transaction_name
±ØÐë·ûºÏ±êʶ·û¹æÔò£¬µ«ÊǽöʹÓÃÍ· 32 ¸ö×Ö·û¡£
@
tran_name_variable
ÊÇÓû§¶¨ÒåµÄÒ»¸ö±äÁ¿Ãû£¬Ëüº¬ÓÐÒ»¸öÊÂÎñÃû£¬¸ÃÊÂÎñÃûÓÃÓÚ¸ú×Ù MS DTC ʵÓù¤¾ßÖеķֲ¼Ê½ÊÂÎñ¡£±ØÐëÓà char
¡¢varchar
¡¢nchar
»ò nvarchar
Êý¾ÝÀàÐÍÉùÃ÷¸Ã±äÁ¿¡£
×¢ÊÍ
Ö´ÐÐ BEGIN DISTRIBUTED TRANSACTION Óï¾äµÄ·þÎñÆ÷ÊÇÊÂÎñ´´½¨ÈË£¬²¢ÇÒ¿ØÖÆÊÂÎñµÄÍê³É¡£µ±Á¬½Ó·¢³öºóÐø
COMMIT TRANSACTION »ò ROLLBACK TRANSACTION Óï¾äʱ£¬Ö÷¿Ø·þÎñÆ÷ÇëÇó MS DTC
ÔÚËùÉæ¼°µÄ·þÎñÆ÷¼ä¹ÜÀí·Ö²¼Ê½ÊÂÎñµÄÍê³É¡£
ÓÐÁ½¸ö·½·¨¿É½«Ô¶³Ì SQL ·þÎñÆ÷µÇ¼ÇÔÚÒ»¸ö·Ö²¼Ê½ÊÂÎñÖУº
·Ö²¼Ê½ÊÂÎ
Ïà¹ØÎĵµ£º
SQL ServerÊý¾Ý¿âÖвð·Ö×Ö·û´®º¯ÊýµÄ¾ßÌå·½·¨£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
¡¡¡¡CREATE¡¡ FUNCTION uf_StrSplit '1.1.2.50','.'
¡¡¡¡(@origStr varchar(7000),¡¡ --´ý²ð·ÖµÄ×Ö·û´®
¡¡¡¡@markStr varchar(100))¡¡¡¡--²ð·Ö±ê¼Ç£¬Èç','
¡¡¡¡RETURNS @splittable table
¡¡¡¡(
¡¡ ¡¡str_id¡¡¡¡varchar(4000) NOT NULL, --±àºÅID ......
Èç¹ûÄãÕýÔÚ¸ºÔðÒ»¸ö»ùÓÚSQL ServerµÄÏîÄ¿£¬»òÕßÄã¸Õ¸Õ½Ó´¥SQL Server£¬Ä㶼ÓпÉÄÜÒªÃæÁÙһЩÊý¾Ý¿âÐÔÄܵÄÎÊÌ⣬ÕâƪÎÄÕ»áΪÄãÌṩһЩÓÐÓõÄÖ¸µ¼£¨ÆäÖдó¶àÊýÒ²¿ÉÒÔÓÃÓÚÆäËüµÄDBMS£©¡£
ÔÚÕâÀÎÒ²»´òËã½éÉÜʹÓÃSQL ServerµÄÇÏÃÅ£¬Ò²²»ÄÜÌṩһ¸ö°üÖΰٲ¡µÄ·½°¸£¬ÎÒËù×öµÄÊÇ×ܽáһЩ¾Ñé----¹ØÓÚÈçºÎÐγÉÒ»¸öºÃµÄÉè¼Æ¡£Õ ......
ͨ¹ýË÷Òý£¬¿ÉÒÔ¼Ó¿ìÊý¾ÝµÄ²éѯËٶȺͼõÉÙϵͳµÄÏìӦʱ¼ä£»¿ÉÒÔʹ±íºÍ±íÖ®¼äµÄÁ¬½ÓËٶȼӿ졣µ«ÊÇ£¬²»ÊÇÔÚÈκÎʱºòʹÓÃË÷Òý¶¼Äܹ»´ïµ½ÕâÖÖЧ¹û¡£ÈôÔÚ²»Ç¡µ±µÄ³¡ºÏÏ£¬Ê¹ÓÃË÷Òý·´¶ø»áÊÂÓëԸΥ¡£ Ë÷ÒýÊÇÒÔ±íÁÐΪ»ù´¡µÄÊý¾Ý¿â¶ÔÏó¡£Ë÷ÒýÖб£´æ×űíÖÐÅÅÐòµÄË÷ÒýÁÐ
¡¡¡¡
ͨ¹ýË÷Òý£¬¿ÉÒÔ¼Ó¿ìÊý¾ÝµÄ²éѯËٶȺͼõÉÙϵͳµÄÏìӦʱ¼ä£ ......
ÔÚSQL Server¿ª·¢ÎÊÌâÖÐÄã¿ÉÄÜ»áÎʵ½µÄÊ®¸öÎÊÌâ:
1¡¢Ê²Ã´Êdz£¼ûµÄ¶Ô±íºÍ×ֶεÄÃû×ÖÔ¼Êø?
¡¡¡¡2¡¢ÓÐûÓпÉÄÜÔÚ²»Á˽âT-SQLµÄÇé¿öϱàд´æ´¢¹ý³Ì?
¡¡¡¡3¡¢T-SQLÖÐÈçºÎ±È½ÏCLR´æ´¢¹ý³ÌºÍº¯ÊýµÄÐÔÄÜ?
¡¡¡¡4¡¢ÎÒÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐʹÓÃÁíÒ»¸ö´æ´¢¹ý³Ì²úÉúµÄ½á¹û?
¡¡¡¡5¡¢ÎÒÈçºÎ½â¾öSQL Server 2005µÄ²¢·¢ÎÊÌâ? ......