0

In SQLCLR, I can detect if I'm inside an SqlContext, and if so, perform additional functions like writing to the pipe.

However, how do I detect if I'm inside a read-only SQL context, such as method with this attribute:

[SqlFunction(DataAccess = DataAccessKind.Read)]
public static void MyMethod()
{
}

The only way I can surmise is to walk back the stack and look for a method decorated with SqlFunctionAttribute?

2
  • Hi @Sören Kuklau, as such the context is not read-only - it is the function that is read-only; which BTW all functions are. E.g. in a function you can never perform actions which have side effects on the data. As a side note, why would you like to know this? Commented Apr 27, 2018 at 12:42
  • Because I have a logging function that can write to the database, and mustn’t try to do so while within an SqlFunction. Commented Apr 28, 2018 at 13:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.