您的位置:首页 > 数据库

遇到一个sql2000的问题,实在搞不懂了,求解决的办法?

2008-12-16 11:56 716 查看
我的SQl语句,其实很简单的,但是就是错误,没办法了!

Code

if exists (select top 1 * from sysobjects where name ='HMonthOtherTotal' and xtype = 'U')

drop table HMonthOtherTotal

Go

Create table HMonthOtherTotal

(

PKID int primary key identity(1,1),

UnitID int,

YearMonth nvarchar(12),

Type1 int default 0,

Type2 int default 0,

Type3 int default 0,

Type4 int default 0

--constraint MonthID unique (YearMonth)

)

Go

if exists (select * from sysobjects where xtype ='p' and name ='HMonthOtherTotal_Insert' )

Drop procedure HMonthOtherTotal_Insert

Go

create procedure HMonthOtherTotal_Insert

(

@PKID int output,

@UnitID int,

@YearMonth nvarchar(12),

@Type1 int,--制止行人、非机动车违章上路(人 辆/次):

@Type2 int,--纠正车辆违章(辆/次):

@Type3 int,--施工安全管理(处/起):

@Type4 int --其它:

)

As

/*Insert into HMonthOtherTotal (UnitID,YearMonth,Type1,Type2,Type3,Type4)

values (@UnitID,@YearMonth,@Type1,@Type2,@Type3,@Type4)

*/

Insert into HMonthOtherTotal(UnitID,YearMonth,Type1,Type2,Type3,Type4)

values (@UnitID,@YearMonth,@Type1,@Type2,@Type3,@Type4)

SET @PKID=SCOPE_IDENTITY();

return

Go

Insert into HMonthOtherTotal(UnitID,YearMonth,Type1,Type2,Type3,Type4)

values (2,'2008年10月',20,120,120,14)

execute HMonthOtherTotal_Insert 2,'2008年12月',20,120,120,14

最后两句是我插入数据的那种犯法,第一种直接插入是可以添加数据的,

但是第二种就不行了,报告错误:

服务器: 消息 8114,级别 16,状态 4,过程 HMonthOtherTotal_Insert,行 0

将数据类型 varchar 转换为 int 时出错。

快点解决啊,就要交项目了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐