while @hd1=0
print '插入成功'
就改为 if @hd1 = 0

解决方案 »

  1.   

    begin transaction hd
    use northwind
    godeclare @hd1 varchar(40)insert into employees 
    (lastname,firstname,title,titleofcourtesy,birthdate)
    values
    ('puter','king','Vice President, Salesd','china','1983-04-07 00:00:00.000')
    select @hd1 = @@error
    if @hd1=0
    print '插入成功'
    go
    save transaction hd3declare @hd2 varchar(40)
    delete
    from employees
    where employeeid=10
    select @hd2=@@error
    if @hd2=0
    print '删除成功'
    go
       
    rollback transaction hd3
    commit transaction
      

  2.   

    while @hd1=0
    begin
    print '插入成功'
    break
    end