tailieunhanh - SQL Server 2000 Stored Procedure Programming phần 3
Phương pháp thứ hai cho ý kiến là nguồn gốc cho SQL Server. Nó phù hợp cho ý kiến ra các khối mã có thể chiều dài nhiều dòng. Một nhận xét như vậy phải được chia từ phần còn lại của mã với một cặp của các dấu phân cách: (/ *) và Đây là chú thích. Tất cả những dòng này sẽ được bỏ qua. | 136 SQL Server 2000 Stored Procedure Programming This type of comment can be nested in another comment defined with the same or a different method -- select from Equipment -- Just for debugging This commenting method is compatible with the SQL-92 standard. Multi-Line Comments . The second commenting method is native to SQL Server. It is suitable for commenting out blocks of code that can span multiple lines. Such a comment must be divided from the rest of the code with a pair of delimiters and This is a comment. All these lines will be ignored. List all equipment. select from Equipment Comments do not have a length limit. It is best to write as much as is necessary to adequately document the code. SQL Server documentation forbids the nesting of multi-line comments. In different versions and in different tools this may or may not generate a syntax error This is a comment. Query Analyzer will understand the following delimiter as the end of the first comment. This will generate a syntax error in some cases. Select from Equipment If you type this code in Query Analyzer the program will not color the last line of explanation as a comment. I am not sure you will be able to see a difference on the paper. However during the execution in Query Analyzer the third line of the comment is ignored and will return a resultset without reporting a syntax error see Figure 4-1 . 137 Chapter 4 Basic Transact-SQL Programming Constructs Figure 4-1. Problems with comments Single-line comments can be nested inside multi-line comments -- List all equipment. Select from Equipment In Chapter 6 when we discuss batches we will illustrate the requirement that multi-line comments not span two or more batches. Documenting Code Again your comments will be of benefit to other developers who may read your code and they will be better still if you make their presence in the code as obvious as possible. It is a favorable although 138 SQL Server 2000 Stored Procedure Programming not required practice
đang nạp các trang xem trước