Is there an equivalent of
PRINT 'hello world'
which can be called from CLR (C#) code?
I’m trying to output some debug information in my function. I can’t run the VS debugger because this is a remote server.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer is that you cannot do the equivalent of
from inside a
[SqlFunction()]. You can do it however from a[SqlProcedure()]usingThis is consistent with T-SQL, where you would get the error “Invalid use of a side-effecting operator ‘PRINT’ within a function” if you stick a PRINT inside a function. But not if you do it from a stored procedure.
For workarounds i suggest:
List<string> messages, and write another table-valued function that returns the contents ofmessages. Of course, the access tomessagesneeds to be synchronized because several threads might try to access it at the same time.[SqlProcedure()]