本文介绍了SQL函数 - 日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复: TSQL如何在用户定义的函数中输出PRINT?
这让我疯狂了。
我有一个我正在尝试调试的功能,但是我不能插入表格,执行打印语句,甚至会引发错误。
I have a function I am trying to debug, but I can't insert into a table, execute a print statement, or even raise an error from it.
SQL返回消息
在函数内无效使用副作用的运算符PRINT。
Invalid use of a side-effecting operator 'PRINT' within a function.
调试这个,我只想知道一个变量在运行时的值?
How can I Debug this, I just want to know the value of a variable while it is running?
推荐答案尝试:
DECLARE @ExecuteString varchar(500) ,@Yourtext varchar(500) @ExecuteString = 'echo '+@Yourtext+' > yourfile.txt) exec master..xp_cmdshell @ExecuteString, no_output使用>创建/覆盖文件,>>创建/追加到文件。您可能需要使用 REPLACE(@Yourtext,'&','^&')来转义& char
use: ">" to create/overwrite file, and ">>" to create/append onto file. you might need to use REPLACE(@Yourtext,'&','^&') to escape the & char
更多推荐
SQL函数
发布评论