SQL Stored Procedure Notes

Source: Internet
Author: User

SET  on SET TRANSACTION Isolation  Level READ Uncommitted SET  on BEGIN TRY END TRY           BEGIN CATCH                    END
1.SET NOCOUNT on
When SET NOCOUNT is on, no count is returned (indicating the number of rows affected by the Transact-SQL statement). When SET NOCOUNT is OFF, the count is returned.
2.SET TRANSACTION Isolation Level READ syntax there are four scenarios
First case:
READ COMMITTED
The function of this sentence is:
Specifies that shared locks are controlled when data is read to avoid dirty reads, but the data can be changed before the transaction ends, resulting in non-repeatable reads or phantom data. This option is the default value for SQL Server.
Second case:
READ Uncommitted
The function of this sentence is:
Performs a dirty read or level 0 isolation lock, which means that no shared lock is issued and an exclusive lock is not accepted. When you set this option, you can perform uncommitted read or dirty reads on the data, and you can change the values within the data before the transaction ends, and the rows can appear in the dataset or disappear from the dataset. This option works the same as setting NOLOCK on all the tables in all statements within a transaction. This is the least restrictive level in the four isolation levels.
The third case:
Repeatable READ
The function of this sentence is:
Locks all data used in the query to prevent other users from updating the data, but other users can insert new Phantom rows into the dataset, and phantom rows are included in subsequent reads of the current transaction. Because concurrency is lower than the default isolation level, you should use this option only when necessary.
Fourth case:
SERIALIZABLE
The function of this sentence is:
Place a range lock on the dataset to prevent other users from updating the dataset or inserting rows into the dataset before the transaction completes. This is the most restrictive level in the four isolation levels. Because the concurrency level is low, you should use this option only when necessary. This option works the same as setting HOLDLOCK on all tables in all SELECT statements within a transaction .

3.SET Xact_abort on
  
Transaction rollback
  

SQL Stored Procedure Notes

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.