use stuDB
go
if exists(select * from sysobjects where name='bank')
drop table bank
if exists(select * from sysobjects where name='transInfo')
drop table transInfo
go
create table bank
(
customerName nvarchar(10) not null,
cardID char(8) not null,
currentMoney money not null
)
go
create table transInfo
(
cardID char(8) not null,
transType nvarchar(4) not null,
transMoney money not null,
transDate datetime not null
)
go
alter table bank
add constraint CK_currentMoney check(currentMoney>=1)
alter table transInfo
add constraint DF_transDate default(getdate()) for transDate
go
insert into bank values('张三','10010001',1000)
insert into bank values('李四','10010002',1)
use stuDB
go
if exists(select * from sysobjects where name='trig_transInfo1')
drop trigger trig_transInfo1
go
create trigger trig_transInfo1
on bank
for insert
as
declare @tempCardID char(8),@tempMoney money
select @tempCardID=cardID,@tempMoney=currentMoney from inserted
if(@tempMoney>=50000)
begin
print '交易金额:'+convert(varchar(8),@tempMoney)
print '贵宾客户'
end
else
begin
print '交易金额:'+convert(varchar(8),@tempMoney)
print '普通客户'
end
insert into transInfo values('@tempCardID','存入',@tempMoney,default)--是不是这句话写得有问题呢
go
insert into bank values('王五','10010003',200)--为什么不能向bank中添加数据呢
select * from bank
select * from transInfo
错误提示
交易金额:200.00
普通客户
服务器: 消息 8152,级别 16,状态 9,过程 trig_transInfo1,行 17
将截断字符串或二进制数据。
语句已终止。
请问是哪里出了问题 请高手指点
[此贴子已经被作者于2007-10-9 16:39:50编辑过]