Interviews2 answers
What are the DisAdvantages of User Defined Functions?
2 Answers
We cannot use temporary tables inside the UDF.
We cannot use Print command inside the UDF.
We can't use the Insert, update and delete command inside the function. We can only use these commands on the table variable defined inside the function.
We cannot use the try catch statement inside the function for the debugging purpose which makes it difficult to debug.
We can't use transaction inside the function.
We can't call the stored procedure from inside the function.
We can't return multiple record sets from a function as we can do in case of Stored Procedure.
Munesh SharmaPosted May 30, 2016, 9:17 PM EDT
UDF that return non-deterministic values are not allowed to be called from inside UDF
GETDATE is an example of a non-deterministic function. Every time the function is called, a different value is returned.
Not every SQL statement or operation is valid within a function.
The following lists enumerate the valid and invalid function operations:
Valid:
Assignment statements
Control-flow statements
Variable declarations
SELECT statements that modify local variables
Cursor operations that fetch into local variables
INSERT, UPDATE, DELETE statement that act upon local table variables
Invalid:
Built-in, nondeterministic functions such as GetDate()
Statements that update, insert, or delete tables or views
Cursor fetch operations that return data to the client
Ajeet MishraPosted Sep 7, 2015, 11:05 PM EDT


