views:

93

answers:

3

In a recent interview I was asked to name a built-in function(s) that cannot be called from inside a stored procedure or a user defined function (both scalar and table-value). I didn't know the answer to the question and gave the generic "I don't know but I'd love to find out."

It turns out after doing a bit of research that I'm no closer to the answer than when I was asked in the interview and now I'm wondering if it was a trick question.

Is this a trick question or is there a real answer?

Thanks.

+5  A: 

My answer would have been the functions that are specific to triggers.

Joe Stefanelli
A: 

I know that Scalar functions are required to be deterministic (e.g. given an input the same results always come back).This means you may not call any non-deterministic functions like NewID or GetDate.

I'm pretty sure that table valued functions don't have this problem.

I'm also unaware of a Built in function that can't be called from a stored proc. What would be the point of the function be?

Obviously this is aside from Joe Stefanelli's answer.

Conrad Frix
I don't follow your point. For example, I use `GETDATE()` in stored procedures all the time.
Joe Stefanelli
NewID and GetDate both can be called in a stored procedure.
Zafer
A: 

Agree with Conrad re: deterministric functions. I would have explained my understanding of this and confirmed with the interviewer that the question was indeed asking about both functions and sprocs.

If their truly is an answer and I had to guess...I'd have likely said "any functions that alter server configuration".

Joe King