TAILIEUCHUNG - beginning microsofl sql server 2008 programming phần 6

(những gì chúng ta đang nói về phần này), hoặc viết tắt một giá trị mặc định thực tế (sẽ được cung cấp nếu chúng tôi không cung cấp một giá trị rõ ràng). Nếu chúng ta đề cập đến một "hạn chế DEFAULT", sau đó chúng ta đang nói về | Chapter 11 Writing Scripts and Batches Setting Variables Using SET SET is usually used for setting variables in the fashion that you would see in more procedural languages. Examples of typical uses would be SET @TotalCost 10 SET @TotalCost @UnitCost Notice that these are all straight assignments that use either explicit values or another variable. With a SET you cannot assign a value to a variable from a query you have to separate the query from the SET. For example USE AdventureWorks2008 DECLARE @Test money SET @Test MAX UnitPrice FROM Order Details SELECT @Test causes an error but USE AdventureWorks2008 DECLARE @Test money SET @Test SELEcT MAX UnitPrice FROM SELECT @Test works just fine. Although this latter syntax works by convention code is never implemented this way. Again I don t know for sure why it s just not done that way but I suspect that it has to do with readability you want a SELECT statement to be related to retrieving table data and a SET to be about simple variable assignments. Setting Variables Using SELECT SELECT is usually used to assign variable values when the source of the information you re storing in the variable is from a query. For example our last illustration would be typically done using a SELECT USE AdventureWorks2008 DECLARE @Test money SELECT @Test MAX UnitPrice FROM SELECT @Test Notice that this is a little cleaner it takes less verbiage to do the same thing . So again the convention on when to use which goes like this Use SET when you are performing a simple assignment of a variable where your value is already known in the form of an explicit value or some other variable. Use SELECT when you are basing the assignment of your variable on a query. 328 Chapter 11 Writing Scripts and Batches I m not going to pick any bones about the fact that you ll see me violate this last convention in many places in this book. Using SET for variable assignment first appeared in version and I .

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.