Four statements help you improve SQLServer's scalability

Source: Internet
Author: User
This article explains how to use LEFTJOIN, CROSSJOIN, and IDENTITY value retrieval technologies to improve the performance of SQL Server-based applications or improve their scalability. What you will encounter: SQL queries in applications cannot respond in the way you want. It either does not return data or takes a surprising amount of time. If

This article explains how to use left join, cross join, and IDENTITY value retrieval to improve SQL Server-based application performance or improve scalability. What you will encounter: SQL queries in applications cannot respond in the way you want. It either does not return data or takes a surprising amount of time. If

This article explains how to use left join, cross join, and IDENTITY value retrieval.ImproveThe performance of SQL Server-based applications or its improvementScalability.

What you will encounter: SQL queries in applications cannot respond in the way you want. It either does not return data or takes a surprising amount of time. If it reduces the speed of enterprise applications, users must wait for a long time. Users want their applications to respond quickly and their reports can return analysis data instantly.

To solve these problems, it is important to find the root cause of the problem. So where should we start? The root cause is generally the database design and access to its query. I will describe four technologies that can be usedImproveThe performance of SQL Server-based applications or its improvementScalability. I will carefully describe the use of LEFT JOIN and CROSS JOIN and the retrieval of IDENTITY values. Remember, there is no magic solution at all. Adjusting your database and its query takes time and analysis, and requires a lot of tests. These technologies have proven to be effective, but some of them may be more suitable for your applications than others.

Return IDENTITY from INSERT

I decided to start with a lot of problems: how to retrieve the IDENTITY value after executing SQL INSERT. Generally, the question is not how to write a query value, but where and when to search. In SQL Server, the followingStatementIt can be used to retrieve the latest SQL statements running on the active database connection.StatementThe created IDENTITY value: SELECT @ IDENTITY.

This SQLStatementIt is not complex, but you need to remember that if the latest SQLStatementIt is not an INSERT statement. If you run this SQL statement on other non-insert SQL connections, the expected value is not obtained. You must run the following code to retrieve the IDENTITY that follows the insert SQL statement and is located on the same connection, as shown below:

INSERT INTO Products (ProductName) VALUES ('Chalk')
SELECT @@IDENTITY

12 3 4 5 6 next page

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.