我的SQl语句,其实很简单的,但是就是错误,没办法了!

 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 时出错。

快点解决啊,就要交项目了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-30
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
  • 2022-02-09
  • 2021-04-28
  • 2021-11-07
  • 2022-02-07
相关资源
相似解决方案