一个简单的sql语句拼接问题
sql 2005 环境
declare @sql varchar(1000)
declare @startHH int
declare @endHH int
set @startHH = 1
set @endHH = 2
set @sql = ''
print @startHH
print @endHH
Select @sql = @sql + ' and datepart(hh, ATable.insertTime) between '+''''+ @startHH + '''' + ' and ' +''''+ @endHH + ''''
declare @sql varchar(1000)
declare @startHH int
declare @endHH int
set @startHH = 1
set @endHH = 2
set @sql = ''
print @startHH
print @endHH
Select @sql = @sql + ' and datepart(hh, ATable.insertTime) between '+''''
+ str(@startHH) + '''' + ' and '
+''''+ str(@endHH) + ''''