使用两个单引号试一下,如下select convert(char(10),passedtime,102),convert(char(8),passedtime,108)
,tollcenterno,tollgateno,roadwayno,
left(cardno, 5),right(cardno, 10),cartype,
charge,carno,
case cardstatus
when ''01'' then ''非法''
when ''02'' then ''正常''
when ''03'' then ''挂失''
when '04' then ''临界''
when ''05'' then ''透支''
when ''06'' then ''销卡''
when ''07'' then ''免费''
when ''08'' then ''无卡''
when ''09'' then ''月卡''
when ''10'' then ''优惠''
end
from PassedCars
where passedtime between @startdatetime and @enddatetime
,tollcenterno,tollgateno,roadwayno,
left(cardno, 5),right(cardno, 10),cartype,
charge,carno,
case cardstatus
when ''01'' then ''非法''
when ''02'' then ''正常''
when ''03'' then ''挂失''
when '04' then ''临界''
when ''05'' then ''透支''
when ''06'' then ''销卡''
when ''07'' then ''免费''
when ''08'' then ''无卡''
when ''09'' then ''月卡''
when ''10'' then ''优惠''
end
from PassedCars
where passedtime between @startdatetime and @enddatetime
解决方案 »
- SQL Server中,怎样接收return的值
- 【急!】SQL SERVER 2005或者2008 如何通过已经有的表,导出创建这个表的sql语句?
- 求叫一个简单的存储
- 高分求答(100),在线等,数据库分页问题
- 关于数据库还原的基础问题
- 求SQL查询语句
- group by 与having的关系
- 救救我!!!!!!!!!!! SQL 2000 打开连接问题(在线等候)急急!!!
- 我的这个视图在 mssql 中查处的记录集怎么和在asp中的不一样!我快发疯了
- 请问如何利用Oricle8 实现top N功能?
- 菜鸟问题,关于数据库单独打包的问题,请高手指点。
- sql server数据库的复制???
,tollcenterno,tollgateno,roadwayno,
left(cardno, 5),right(cardno, 10),cartype,
charge,carno,
case cardstatus
when ''01'' then ''非法''
when ''02'' then ''正常''
when ''03'' then ''挂失''
when ''04'' then ''临界''
when ''05'' then ''透支''
when ''06'' then ''销卡''
when ''07'' then ''免费''
when ''08'' then ''无卡''
when ''09'' then ''月卡''
when ''10'' then ''优惠''
end
from PassedCars
where passedtime between'''+ @startdatetime +''' and '''+@enddatetime+''''上面的@startdatetime 我不知道你的格式!
我给你一个特殊的例子:
declare @sqlcmd varchar(1000)
set @sqlcmd='select convert(char(10),passedtime,102),convert(char(8),passedtime,108)
,tollcenterno,tollgateno,roadwayno,
left(cardno, 5),right(cardno, 10),cartype,
charge,carno,
case cardstatus
when ''01'' then ''非法''
when ''02'' then ''正常''
when ''03'' then ''挂失''
when ''04'' then ''临界''
when ''05'' then ''透支''
when ''06'' then ''销卡''
when ''07'' then ''免费''
when ''08'' then ''无卡''
when ''09'' then ''月卡''
when ''10'' then ''优惠''
end
from PassedCars
where passedtime between convert(datetime,'''+ convert(varchar(100),getdate()) +''') and convert(datetime,'''+convert(varchar(100),getdate())+''')'
print @sqlcmd