TAILIEUCHUNG - Hướng dẫn học Microsoft SQL Server 2008 part 61

Tuyên bố chấm dứt Các tiêu chuẩn ANSI SQL là đặt một dấu chấm phẩy (;) vào cuối mỗi lệnh để chấm dứt nó. Khi lập trình T-SQL, dấu chấm phẩy sẽ là tùy chọn. Hầu hết các sản phẩm cơ sở dữ liệu khác (bao gồm cả truy cập) để yêu cầu chấm phẩy. Có một vài quy tắc về việc sử dụng dấu chấm phẩy: ■ Không đặt một sau khi một TRY END. ■ Không được đặt một sau khi một điều kiện IF hoặc WHILE. . | Part IV Developing with SQL Server An application can submit a T-SQL batch using ADO or ODBC for execution. A SQL script may be executed by running the SQLCMD command-line utility and passing the SQL script file as a parameter. The SQLCMD utility has several parameters and may be configured to meet nearly any command-line need. T-SQL formatting Throughout this book T-SQL code has been formatted for readability this section specifies the details of formatting T-SQL code. Statement termination The ANSI SQL standard is to place a semicolon at the end of each command in order to terminate it. When programming T-SQL the semicolon is optional. Most other database products including Access do require semicolons. There are a few rules about using the semicolon Don t place one after an END TRY. Don t place one after an IF or WHILE condition. You must place one before any CTE. A statement terminator is required following a MERGE command. Best Practice As a best practice and for improved readability I recommend using the semicolon. In future versions of SQL Server this may become a requirement so making the change now may pay off later. Line continuation T-SQL commands by their nature tend to be long. I have written production queries with multiple joins and subqueries that were a few pages long. I like that T-SQL ignores spaces and end-of-line returns. This smart feature means that long lines can be continued without a special line-continuation character which makes T-SQL code significantly more readable. Comments T-SQL accepts both simple comments and bracketed comments within the same batch. The simple comment begins with two hyphens and concludes with an end-of-line -- This is a simple comment Simple comments may be embedded within a single SQL command 562 Programming with T-SQL 21 SELECT FirstName LastName -- selects the columns FROM Persons -- the source table WHERE LastName LIKE Hal -- the row restriction Management Studio s Query Editor can apply

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.