存储过程执行问题 [英] Store Procedure execute problem

查看:68
本文介绍了存储过程执行问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了以下商店流程。但是当我运行时出现以下错误:

消息241,级别16,状态1,过程sp_backupManpowerCollection,第6行

转换日期和/或时间时转换失败来自字符串。



商店程序如下:

创建proc sp_backupManpowerCollection

@ ATTFromDate datetime ,

@ ATTToDate datetime,

@Location nvarchar(50)

as

INSERT INTO tblBacManpoweCollection

SELECT EmpCode,ATTdate,LineCode,LineName,DesigCode,Designation,CompanyName,UnitName,DeptName,SecName,InHour,

InMin,OutHour,OutMin,Location,Counter,TotalOTHour,DayFlag, ProcessTime FROM tblManpowerCollection

在'@ ATTFromDate'和'@ ATTToDate'和Location ='@ Location'之间的地址

删除tblManpowerCollection,其中'@ ATTFromDate'和'@之间的ATTdate ATTToDate'和位置= @位置

I have created the following store procedure. but when i run it arises the following error :
"Msg 241, Level 16, State 1, Procedure sp_backupManpowerCollection, Line 6
Conversion failed when converting date and/or time from character string.
"
The store procedure is as follows :
Create proc sp_backupManpowerCollection
@ATTFromDate datetime,
@ATTToDate datetime,
@Location nvarchar(50)
as
INSERT INTO tblBacManpoweCollection
SELECT EmpCode, ATTdate, LineCode,LineName,DesigCode,Designation,CompanyName,UnitName,DeptName,SecName,InHour,
InMin,OutHour,OutMin,Location,Counter,TotalOTHour,DayFlag,ProcessTime FROM tblManpowerCollection
WHERE ATTdate between '@ATTFromDate' and '@ATTToDate' and Location='@Location'
delete tblManpowerCollection where ATTdate between '@ATTFromDate' and '@ATTToDate' and Location=@Location

推荐答案

删除日期参数的单引号( @ATTFromDate & @ATTToDate
Remove the single-quotes for Date parameters(@ATTFromDate & @ATTToDate)


在WHERE子句中,不应使用单引号作为日期时间参数。



试试这个:

In the WHERE clause, you shouldn't use single quotes for your datetime parameters.

Try this:
Create proc sp_backupManpowerCollection
@ATTFromDate datetime,
@ATTToDate datetime,
@Location nvarchar(50)
as
INSERT INTO tblBacManpoweCollection
SELECT EmpCode, ATTdate, LineCode,LineName,DesigCode,Designation,CompanyName,UnitName,DeptName,SecName,InHour,
InMin,OutHour,OutMin,Location,Counter,TotalOTHour,DayFlag,ProcessTime FROM tblManpowerCollection
WHERE ATTdate between @ATTFromDate and @ATTToDate and Location='@Location'
delete tblManpowerCollection where ATTdate between @ATTFromDate and @ATTToDate and Location=@Location 


这篇关于存储过程执行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆