当前位置: 代码迷 >> Sql Server >> SQL Server救急解决办法
  详细解决方案

SQL Server救急解决办法

热度:74   发布时间:2016-04-27 20:37:03.0
SQL Server救急!!!!!!!
SET   @SQLSTR   =   'SELECT   TOP   100   from   T_Table1   where   publishTime   between   '+convert(varchar(100),   @StartTime,23) '+ '   and   '+   convert(varchar(100),   @OverTime,23)

传入参数后总是无法返回记录,请问是什么问题啊

------解决方案--------------------
SET @SQLSTR = 'SELECT TOP 100 from T_Table1 where publishTime between ' ' '+convert(varchar(100), @StartTime,23)+ ' ' ' and ' ' '+ convert(varchar(100), @OverTime,23)+ ' ' ' '
------解决方案--------------------
declare @StartTime datetime
declare @OverTime datetime
set @StartTime= '2007-1-1 '
set @OverTime= '2007-4-1 '
declare @SQLSTR nvarchar(4000)
------------------------------------------------
SET @SQLSTR = 'SELECT TOP 100 * from T_Table1 where convert(varchar(100), Convert(datetime,publishTime),23) between ' ' '+ convert(varchar(100), @StartTime,23)+ ' ' ' and ' ' '+convert(varchar(100), @OverTime,23)+ ' ' ' '
------------------------------------------------
print @SQLSTR


  相关解决方案