SQL Server Master----transactions from Getting Started

Source: Internet
Author: User

-------------Transaction----------------my understanding (when executing several statements, the other statements are not enough to be executed as long as one statement is unsuccessful)--transactions: The execution of multiple operations as a separate logical unit is a transactional--------Features: Multiple operations are successful only if they are successful, as long as there is an execution failure that should be the overall failure, success can be committed, failed can be rolled backGrammarbegin TransactionTr_insert--start Things (name pickbeginTryInsert  intoQ_user (Ulogname)Values('DSF') Insert  intoQ_user (Ulogname)Values('DSF')  --violates the UNIQUE KEY constraint "Uq__q_user__07e32c94386667d8". cannot be in the object "dbo." Insert duplicate key in Q_user. The repeating key value is (DSF). Will error --all successfully committed transactions Commit TranTr_insert--Here's the nameEndTrybeginCatch--Error getting exception ROLLBACK statement block rollback TranEndCatchSelect *  fromQ_userCreate procExectran@sql1  nvarchar( +),@sql2  nvarchar( +),@rtn nvarchar( +) Output asbegin TranTR_EXEC2beginTryexec @sql1    exec @sql2    Set @rtn='Success'    Commit TranExectranEndTrybeginCatchSet @rtn=@ @ERROR    rollback TranTR_EXEC2EndCatchGoDrop procExectranDeclare @rtn nvarchar( -)execExectran'INSERT into Q_user values (,,,,,,,,)','SQL2',@rtnOutputPrint @rtn

SQL Server Master----transactions from Getting Started

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.