当前位置: 代码迷 >> Sql Server >> “SQL”语句如何调试
  详细解决方案

“SQL”语句如何调试

热度:56   发布时间:2016-04-27 13:25:36.0
“SQL”语句怎么调试?
“SQL”语句怎么调试?

例如,SQL语句如下:

If @RowCnt1=1
Begin
If @MeterNo='123255'
Begin
set @SpecialType=( select SpecialMonitorName from SpecialMonitorItem 

where [email protected]) 
set @TempQty= (select AVG(Qty) from specialmonitordata where 

meterno='123319' and Replace((Replace(CONVERT(varchar(13), DATime, 20),'-','')),'

','')[email protected])

问题:如果要看语句中的“Replace((Replace(CONVERT(varchar(13), DATime, 20),'-','')),' ','')”的值,应该怎么办?

设断点么?


------解决方案--------------------
print()
------解决方案--------------------
探讨
谢谢,除了“print()”,还有其它方式么,比如像“VS2010”中的那样?

------解决方案--------------------
探讨
引用:

引用:
谢谢,除了“print()”,还有其它方式么,比如像“VS2010”中的那样?


sql2008有这个功能


小弟用的就是“Sql2008”,怎么使呢?调试?

------解决方案--------------------
上张图片

------解决方案--------------------
问题1 是因为缺少 end 语句
问题2 不知道你想要什么行号,给你一条语句参考下
SQL code
select row_number() over(order by getdate()) as [rank],* from sysobjects
------解决方案--------------------
补充一句,
如果你的查询结果是多数据 赋给一个变量 也是会报错的,
你要确保你查询 出来的值 只有一条记录 才可以赋值给一个变量..
探讨

这样对吧?

If @InsertCount>0
Begin
Select @MeterNo = MeterNo,@DADay = DADay,
@DAHour = DAHour,@SumQty = SumQty
From EnergyDataSumByHourN;
Set @CopNo=(select [email protected][email protected]+'')
Print @Cop……
  相关解决方案