Writing SQL statements in a program

Source: Internet
Author: User

There are many discussions about stored procedures in the garden, many people suggest that the SQL statement in the program, this essay discusses the SQL statement in the process of writing.

1string strSQL = "SELECT [Addressid], [AddressLine1], [AddressLine2], [City], [StateProvinceID], [PostalCode], [ ROWGUID], [ModifiedDate] from [AdventureWorks]. [Person]. [Address] WHERE city = ' Bothell ' ORDER by Addressid;

This is the most common form of writing, and is widely used in development.

String strSQL = "Select" +
"[Addressid]," +
"[AddressLine1]," +
"[AddressLine2]," +
"[City]," +
"[StateProvinceID]," +
"[PostalCode]," +
"[Rowguid]," +
"[ModifiedDate]" +
"From" +
"[AdventureWorks]. [Person]. [Address] " +
"WHERE" +
"City = ' Bothell '" +
"ORDER BY" +
"Addressid";

The second type of writing, in addition to making people more comfortable, there is no benefit.


The above figure shows a better way to reduce maintenance difficulties, improve development efficiency, team development should be the small details of the provisions. Of these, the 1th in the diagram can look at the SQL statements generated in SQL Server 2005 from the following Figure menu, but don't know why SQL Server 2005 's Query Editor generates SQL statements that are still lame. Microsoft can fully parse SQL statements and make them a more development-friendly format.




The above figure shows a better way to reduce maintenance difficulties, improve development efficiency, team development should be the small details of the provisions. Of these, the 1th in the diagram can look at the SQL statements generated in SQL Server 2005 from the following Figure menu, but don't know why SQL Server 2005 's Query Editor generates SQL statements that are still lame. Microsoft can fully parse SQL statements and make them a more development-friendly format.



If two tables are connected, statements such as INNER (Left/right) Join should also be written on one line. In addition, it is recommended to use a simpler English alias instead of the Chinese table name.



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.