日期:2014-05-19  浏览次数:20519 次

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