遇到一个sql2000的问题,实在搞不懂了,求解决的办法?
生活随笔
收集整理的這篇文章主要介紹了
遇到一个sql2000的问题,实在搞不懂了,求解决的办法?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我的SQl語句,其實很簡單的,但是就是錯誤,沒辦法了!
Codeif?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 時出錯。
快點解決啊,就要交項目了。
轉載于:https://www.cnblogs.com/Longkin/archive/2008/12/16/1355878.html
總結
以上是生活随笔為你收集整理的遇到一个sql2000的问题,实在搞不懂了,求解决的办法?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 培训是一种乐趣(3)
- 下一篇: DOS下从硬盘安装XP系统方法与要点