There are many discussions about stored procedures in the garden. Many people suggest writing SQL statementsProgram.
1 String 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 method and is widely used in development.
1 String Strsql = " Select " +
2 " [Addressid], " +
3 " [Addressline1], " +
4 " [Addressline2], " +
5 " [City], " +
6 " [Stateprovinceid], " +
7 " [Postalcode], " +
8 " [Rowguid], " +
9 " [Modifieddate] " +
10 " From " +
11 " [Adventureworks]. [person]. [address] " +
12 " Where " +
13 " City = 'bothell' " +
14 " Order " +
15 " Addressid " ;
16
The second method has no advantages except making people comfortable.
The statement shown here should be better, which can reduce the maintenance difficulty and improve the development efficiency. These small details should be specified in team development. The first point shown in the figure shows the SQL statements generated through the menu in SQL Server 2005, but I don't know why the SQL statements generated by the SQL Server 2005 query editor are still so lame. Microsoft can parse SQL statements and make them more suitable for development.
If two tables are connected, the inner (left/right) join statements should also be written in one row. In addition, we recommend that you use a simpler english alias instead of a Chinese table name.
It's easy, right? If you have a better solution for writing SQL statements, please let me know.