日期:2014-05-18  浏览次数:20393 次

mssql 2000 运行存贮过程时出错,请帮助看一下,谢谢!
----在sqlquery 中运行结果:提示“从字符串转换为 datetime 时发生语法错误。
感到奇怪的是定义参数中没有日期类型的呀!

exec user_info_ADD '1','2','3','4','5','6','7','8','9','10'
出错提示:
服务器: 消息 241,级别 16,状态 1,过程 User_info_ADD,行 20
从字符串转换为 datetime 时发生语法错误。



------存贮过程如下
create PROCEDURE User_info_ADD
@userno varchar(10),
@username varchar(50),
@userpwd varchar(6),
@Empname varchar(50),
@userrole varchar(50),
@usersts varchar(10),
@startdate varchar(8),
@enddate varchar(8),
@regioncode nchar(10),
@deptno nchar(10)

 AS 

INSERT INTO [gy_User_info](
[userno],[username],[userpwd],[Empname],[userrole],[usersts],[startdate],[regioncode],[deptno],[enddate]
)VALUES(@userno,@username,@userpwd,@Empname,@userrole,@usersts,@startdate,@regioncode,@deptno,@enddate  
)



------解决方案--------------------
你表里面有datetime类型的字段
------解决方案--------------------
SQL code
create PROCEDURE User_info_ADD
@userno varchar(10),
@username varchar(50),
@userpwd varchar(6),
@Empname varchar(50),
@userrole varchar(50),
@usersts varchar(10),
@startdate datetime,
@enddate datetie,
@regioncode nchar(10),
@deptno nchar(10)

 AS  

INSERT INTO [gy_User_info](
[userno],[username],[userpwd],[Empname],[userrole],[usersts],[startdate],[regioncode],[deptno],[enddate]
)VALUES(@userno,@username,@userpwd,@Empname,@userrole,@usersts,@startdate,@regioncode,@deptno,@enddate   
)

------解决方案--------------------
SQL code
create PROCEDURE User_info_ADD
@userno varchar(10),
@username varchar(50),
@userpwd varchar(6),
@Empname varchar(50),
@userrole varchar(50),
@usersts varchar(10),
@startdate datetime,
@enddate datetime,
@regioncode nchar(10),
@deptno nchar(10)

 AS  

INSERT INTO [gy_User_info](
[userno],[username],[userpwd],[Empname],[userrole],[usersts],[startdate],[regioncode],[deptno],[enddate]
)VALUES(@userno,@username,@userpwd,@Empname,@userrole,@usersts,@startdate,@regioncode,@deptno,@enddate   
)

------解决方案--------------------
SQL code
exec user_info_ADD '1','2','3','4','5','6','2012-07-12','2012-07-12','9','10'