Bonus Reference Transact-SQL

In Chapter 20, you built SQL statements to retrieve and update rows in a database. You also learned all the variations of the SELECT statement. Some restrictions, however, can’t be expressed with a WHERE clause, no matter how complicated. To perform complicated searches, many programmers would rather write an application to retrieve the desired rows, process them, and then display some results. The processing could include running totals, formatting of the query’s output, calculations involving multiple rows of the same table, and so on. | Bonus Reference Transact-SQL In Chapter 20, you built SQL statements to retrieve and update rows in a database. You also learned all the variations of the SELECT statement. Some restrictions, however, can’t be expressed with a WHERE clause, no matter how complicated. To perform complicated searches, many programmers would rather write an application to retrieve the desired rows, process them, and then display some results. The processing could include running totals, formatting of the query’s output, calculations involving multiple rows of the same table, and so on. Most database management systems include extensions, which enhance SQL and make it behave more like a programming language. SQL Server provides a set of statements known as Transact-SQL (T-SQL). T-SQL recognizes statements that fetch rows from one or more tables, flow-control statements like IF ELSE and WHILE, and numerous functions to manipulate strings, numeric values, and dates, similar to Visual Basic’s functions. With T-SQL you can do everything that can be done with SQL, as well as program these operations. At the very least, you can attach lengthy SQL statements to a database as stored procedures, so that you can call them by name. In addition, you can use parameters, so that the same procedure can act on different data. This chapter is an overview of T-SQL and demonstrates the basic topic with stored proce- dures that perform complicated tasks on the server. We’ll start with the COMPUTE BY state- ment, which allows you to calculate totals on groups of the rows retrieved from the database. This statement looks and feels very much like the straight SQL statements, yet it’s not part of standard SQL. Then we’ll look at T-SQL in depth. If you need to look up a function or how to declare a stored procedure’s arguments, you can use this chapter as reference material. If you’re new to T-SQL, you should read this material, because T-SQL is a powerful language, and if you’re working with or plan to switch

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
30    332    1    25-04-2024
Đã 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.