当前位置: 代码迷 >> 其他数据库 >> 存储过程中传递时间参数的有关问题
  详细解决方案

存储过程中传递时间参数的有关问题

热度:6528   发布时间:2013-02-26 00:00:00.0
存储过程中传递时间参数的问题
这是我写的一个存储过程,实现分页

create proc Proc_ds

@page int,

@times datetimeas declare 

@str varchar(1000)declare 

@thispage int 

set @thispage = @page*10set @str = 'select top 10 * from outPut where id not in (select top '+cast(@thispage as varchar)+' id from outPut) and times ='+@times+' order by thick'

execute (@str)

exec Proc_ds '0','2009-4-4'

exec Proc_ds '0','2009-04-04 00:00:00.000'

这两种传时间参数的方式,都会报“从字符串转换为 datetime 时发生语法错误。”的错误请高手帮忙指点一下



------解决方案--------------------------------------------------------
'+@times+'是不是应该改成"'+@times+'",或者类似的?
  相关解决方案