Trong ví dụ sau đây, bạn có thể thấy một thủ tục lưu trữ được thiết kế để hỗ trợ các loại thử nghiệm này: Thay đổi Thủ tục prGetInventoryProperties_2 - Return dấu phẩy phân cách danh sách các tài sản - được mô tả tài sản. - Tức là: | 363 Chapter 9 Special Types of Procedures @@IDLE @@IO_BUSY @@MAX_CONNECTIONS @@PACK_RECEIVED @@PACK_SENT @@PACKET_ERRORS @@TOTAL_READ @@TOTAL_WRITE GETDATE NEWID RAND TEXTPTR Notice that GetDate is also among the forbidden functions. If you try to use it inside a user-defined function SQL Server will report an error as shown in Figure 9-5. Figure 9-5. A limitation on use of built-in functions in user-defined functions 364 SQL Server 2000 Stored Procedure Programming Encryption As is the case with stored procedures functions can be encrypted so that nobody can see their source code. The developer just needs to create or alter the function using the With Encryption option. Schema-Binding A new option With Schemabinding allows developers to schema-bind a user-defined function to database objects such as tables views and other used-defined functions that it references. Once the function is schema-bound it is not possible to make schema changes on underlying objects. All attempts to drop the objects and all attempts to Alter underlying objects which would change the object schema will fail. A function can be schema-bound only if all of the following criteria are satisfied All user-defined functions and views referenced by the function must already be schema-bound. All database objects that the function references must reside in the same database as the function. References to database objects cannot have server or database qualifiers. Only object owner qualifiers and object identifiers are allowed. The user who executes the Create or Alter Function statement has References permissions on all referenced database objects. Table-Valued User-Defined Functions Since SQL Server 2000 has a table datatype it is possible to design a user-defined function that returns a table. The primary use of table-valued user-defined functions is similar to the use of views. However these functions are far more flexible and provide additional functionality. You can use a table-valued .