Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL调试打印_Sql_Sql Server 2005_Debugging_Sqlcmd - Fatal编程技术网

SQL调试打印

SQL调试打印,sql,sql-server-2005,debugging,sqlcmd,Sql,Sql Server 2005,Debugging,Sqlcmd,如果您的存储过程中出现了100次“打印”,那么在调试非调试过程时,是否有一种很好的方法将它们全部打开/关闭 我可以添加一个变量@isdebug=1 然后,做一些类似的事情 IF@isdebug=1打印@yourvar 然后根据需要将@isdebug设置为0或1。 有更好的方法吗?没有,这也是我在procs中的方法 IF @debug = 1 BEGIN print 'Something' --or insert into a log table if you need the rows of a

如果您的存储过程中出现了100次“打印”,那么在调试非调试过程时,是否有一种很好的方法将它们全部打开/关闭

我可以添加一个变量
@isdebug=1

然后,做一些类似的事情
IF@isdebug=1打印@yourvar

然后根据需要将
@isdebug
设置为0或1。
有更好的方法吗?

没有,这也是我在procs中的方法

IF @debug = 1
BEGIN
print 'Something'
--or insert into a log table if you need the rows of a temp table 
--or the results of a calculation
END

不,这也是我在procs中所做的

IF @debug = 1
BEGIN
print 'Something'
--or insert into a log table if you need the rows of a temp table 
--or the results of a calculation
END

这个想法的一个扩展是设置一个控制字符串。这给了我们更多的选择,而不是开或关

例如: 存储过程参数声明

   (@Debug     varchar(5),  -- use bit wise control for debugging, currently 5 levels.
驱动测试/调试块的简单子字符串

if substring(@Debug, 1, 1) = '1' 
对于测试运行,您可以为@Debug输入“10001”,以便“级别”1调试显示(即初始化),并且仅为您正在测试/调试的代码的子部分显示“级别”5调试


你也可以通过使用数值(即2-9)来扩展这个想法。但是这可能太过分了。

这个想法的扩展是设置一个控制字符串。这给了我们更多的选择,而不是开或关

例如: 存储过程参数声明

   (@Debug     varchar(5),  -- use bit wise control for debugging, currently 5 levels.
驱动测试/调试块的简单子字符串

if substring(@Debug, 1, 1) = '1' 
对于测试运行,您可以为@Debug输入“10001”,以便“级别”1调试显示(即初始化),并且仅为您正在测试/调试的代码的子部分显示“级别”5调试

你也可以通过使用数值(即2-9)来扩展这个想法。但这可能太过分了。

请参见