SQL函数

编程入门 行业动态 更新时间:2024-10-23 21:29:47
本文介绍了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函数

本文发布于:2023-10-16 11:56:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!