TAILIEUCHUNG - Create and Call SQL Server 2000 User-Defined

6,8 Tạo và Call SQL Server 2000 User-Defined Chức năng Trong SQL Server 2000, tôi đã nghe nói rằng bạn có thể tạo các chức năng người dùng định nghĩa (UDFs). | Create and Call SQL Server 2000 User-Defined Functions In SQL Server 2000 I have heard that you can create user-defined functions UDFs . Where would you use UDFs and how do you create and call them from within T-SQL Technique UDFs have been used for years in application development languages. You can now create them in SQL Server 2000 as well. Creating SQL Server 2000 UDFs You can create UDFs in SQL Server 2000 by using the CREATE FUNCTION command. Normally you would do this using the Enterprise Manager or some tool but here you will learn how to do it using . Following is the function that will be created CREATE FUNCTION udf_ShowProdAndCat @UnitPriceParm money RETURNS @ProdAndCatTab TABLE ProductID int ProductName nvarchar 80 CategoryName nvarchar 80 UnitPrice int AS BEGIN INSERT @ProdAndCatTab SELECT FROM Products AS P INNER JOIN Categories AS C ON WHERE @UnitPriceParm RETURN END This function definitely looks a lot different from functions you have created in other languages but it doesn t look as funky when you remember you are using T-SQL commands. Passing Parameters to SQL Server UDFs The parameter that is passed starts with the @ symbol much like local variables that were discussed in How-To . You will also want to declare the data type. Returning Scalar or Table Types from SQL Server UDFs When returning values from a UDF you will either pass back a scalar type which is actually a single value of one of the standard data types or pass back a new Table data type. The example for this How-To creates and returns a Table data type specified with the following lines of code RETURNS @ProdAndCatTab TABLE ProductID int ProductName nvarchar 80 CategoryName nvarchar 80 UnitPrice int By including the opening and closing parentheses you can specify and return an entire table s worth of data but be careful not to because performance would not be good. This is the same

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.