-------------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