Re: Design question: Nested views and functions? I should note that in the function examples I posted, the UDFs return
single scalar values, not result sets.
Thus, a more accurate example would be:
CREATE FUNCTION udf1(@id INT) RETURNS INT
AS SELECT SUM(col1) FROM tbl1
WHERE id = @id
CREATE FUNCTION udf2(id) RETURNS INT
AS SELECT COUNT(*) FROM udf1
WHERE col2 < udf2(id)
Application uses: SELECT udf2(id)
Note: examples do not reflect actual app logic, but simply demonstrate
a nesting example. |