આર્કાઇવ્ઝ

SQL સર્વર માં રોલબેક ટ્રાન્ઝેક્શન 2005

SQL સર્વર 2005 નવા SQL સર્વર માં વ્યવહારો રોલબેક કરવા માટે માર્ગ intoduced 2005

સેટ XACT_ABORT પર

જ્યારે XACT_ABORT પર છે. ભૂલ નિવેદનોમાં આવી ત્યારે ટી એસક્યુએલ નિવેદનો આપમેળે ટ્રાન્ઝેક્શન રોલબેક થશે.

સેટ XACT_ABORT પર

USE Emp
Begin Tran
EmpInfo મૂલ્યો માં દાખલ(1)
EmpInfo મૂલ્યો માં દાખલ(1) — This statement will raise the primary key error
EmpInfo મૂલ્યો માં દાખલ(2)
Commit Tran

The first line of statment will execute without any errors. The primary key error will raise in second line. But the entire block transaction will not be commited because the XACT_ABORT in on.

1 comment to RollBack Transaction in SQL Server 2005

  • noreply@blogger.com (ટોડ)

    You should note that XACT_ABORT terminates the current *batch*, not the entire command. Batches are separated with the GO keyword. Execution will continue at the beginning of the next batch.

    This feature is also in SQL Server 2000, though it behaves slightly differently for various errors.

    In SQL 2000, there are cases where XACT_ABORT fails to rollback the transaction automatically.

    For instance:

    Inserting into an invalid column name.

    Inserting into a primary key with IDENTITY_INSERT OFF.

    Executing a SELECT that uses a non-existent UDF.

    These types of errors are usually due to a poorly authored command, so they don’t occur in the day-to-day operation of your program unless someone alters the schema. But I account for their possibility when authoring database update scripts when deploying a new version of a project, just in case deployment doesn’t go as planned.

    There are ways to handle these errors. Your COMMIT should be in the batch performing the DML statements. After the batch (after the GO keyword) you can check the @@TRANCOUNT to see if it’s greater than zero and act accordingly. Usually ROLLBACK the transaction.

    Transactions can span batches, so you can execute a rollback in a subsequent batch.

એક જવાબ છોડો

તમે ઉપયોગ કરી શકો છો આ એચટીએમએલ ટૅગ્સ

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>