SQL函数 - 日志记录 [英] SQL Functions - Logging
本文介绍了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函数 - 日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文