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

Bởi vì kết quả thiết lập các thủ tục lưu trữ được trả về thông qua một chức năng được sử dụng bởi một nguồn dữ liệu trong mệnh đề FROM của câu lệnh SELECT, một mệnh đề WHERE có thể tiếp tục giảm sản lượng của các thủ tục lưu trữ. Trong khi kỹ thuật này cho phép việc sử dụng các thủ tục được lưu trữ trong một câu lệnh SELECT, nó không phải là tối ưu hóa như kỹ thuật truyền bất kỳ hạn chế hàng với thủ tục lưu trữ cho chế biến trong các thủ. | Part IV Developing with SQL Server Because the result set of the stored procedure is returned via a function being used by a data source in the FROM clause of the SELECT statement a WHERE clause can further reduce the output of the stored procedure. While this technique enables the use of stored procedures within a SELECT statement it s not as optimized as the technique of passing any row restrictions to the stored procedure for processing within the stored procedure. The only benefit of using openquery is that it enables a complex stored procedure to be called from within an ad hoc query. For the purpose of the following code assume that a linked server connection has been established to the local server with the name NOLI SELECT FROM OpenQuery MAUINOLI EXEC WHERE ProductCategoryDescription Like stuff Result ProductCategoryName ProductCategoryDescription OBX OBX stuff Toy Kids stuff Best Practice If you need to call complex code within a SELECT statement using openquery to call a stored procedure works but the syntax is a bit bizarre. A better method is to use a CASE expression or create a user-defined function. Executing remote stored procedures Two methods exist for calling a stored procedure located on another server a four-part name reference and a distributed query. Both methods require that the remote server be a linked server. Stored procedures may only be called remotely they may not be created remotely. The remote stored procedure may be executed by means of the four-part name For example the following code adds a new product category to the OBXKites database on Noli s my development server second instance of SQL Server EXEC MAUINoli SQL2COPENHAGEN . Food Eatables 612 Developing Stored Procedures 24 Alternately the OpenQuery function can be used to call a remote stored procedure OpenQuery linked server name exec EXEC stored .

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.