Differences between use of table aliases and Oracle in delete and update in SQL Server _mssql

Source: Internet
Author: User
Tags aliases

Yesterday found in the program data analysis results are not, after the analysis, the original data is still, the value of the field is cumulative. Heart said, not Ah, is to regenerate records before the analysis of AH. Did you forget to delete it? Check the code, found that there are DELETE statements. Then execute in Query Analyzer, error. Try again and again, understand, Delete from does not recognize table name alias! Thinking back, the original program after the main test in Oracle, SQL Server has not been carefully measured.

The reason to use aliases is because the where conditions need to use a subquery to write some conditions, the following is not written so complex, only to explain the problem.

Conclusion:

(Oracle applies) DELETE from TABLEA A WHERE a.field1=10
(SQL Server applies) DELETE TABLEA from TABLEA A WHERE a.field1=10
DELETE from TABLEA WHERE TABLEA (Ora\sql applies). field1=10

Two points experience:

1, testing to be comprehensive;
2, to be confident, write procedures to consider the situation is quite complete.

Update situation

Update T_report A
Set a.status= ' 1 '
where a.report_seq=1234

Execution failed

Update a
Set a.status= ' 1 '
From T_report A
where a.report_seq=1234

Successful execution

So to do a common program, do not use aliases

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.