T-SQL (3)-Batch Processing

Source: Internet
Author: User

For example, if your customer comes to your house, your mother will give you two yuan to buy a bottle of beer at the store for the guests to drink. As a result, the guests were not enough to drink, and your mom was afraid of waste. I gave you two yuan to let you go downstairs and buy another bottle. The result was not enough. I asked you to go downstairs and buy another bottle, let you buy another bottle ...... What do you say at this time? You will be impatient to answer: Mom, please, don't let me buy one bottle at a time, just a few more bottles at a time?

 

The same is true for SQL statements. Because SQL Server is a network database, a server may have many remote clients. If one SQL statement is sent at a time on the client, the client returns the result; then, an SQL statement is sent and then returned, which is too inefficient. To improve efficiency, SQL Server introduces the concept of batch processing.

 

Q batch processing is a group that contains one or more SQL statements, which are sent from an application to SQL Server for execution at a time.

Q SQL Server compiles batch processing statements into an executable unit, which is called an execution plan. Execute one statement in the execution plan each time

 

Select * From stuinfo

Select * From stumarks

Update stumarks

Set writtenexam = writtenexam + 2

Go

L go is a sign of batch processing, indicating that SQL Server compiles these T-SQL statements into an execution unit to improve execution efficiency

L generally, some logic-related business operation statements are placed in the same batch, which is completely determined by the business requirements and code writers.

L rules: if it is a database creation, table creation statement, and stored procedures and views that we will learn later, you must add the go batch processing mark at the end of the statement.

 

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.