CREATE TRIGGER del ON dbo.CreditInsurance 
FOR DELETE 
AS
  SET NOCOUNT ON
  
  delete from Gatheringprawn
  where Gatheringprawn.insurecode = (select insurecode from deleted)

解决方案 »

  1.   

    还是不行啊,还是报错:
    subquery returned more than 1 value 
    this is not permitted when the subquery fallows = <,<=,>=.>
    or the subquery is uesed as an expression
      

  2.   

    CREATE TRIGGER del ON dbo.CreditInsurance 
    FOR DELETE 
    AS
      
      delete Gatheringprawn
      where Gatheringprawn.insurecode in (select insurecode from deleted)
      

  3.   

    还是不行啊,55555555555~~~~~~~
    还是报错:
    subquery returned more than 1 value 
    this is not permitted when the subquery fallows = <,<=,>=,>,!=
    or the subquery is uesed as an expression
     到底是什么原因呢?应该没有其他因素的影响啊,我只是在数据库中写了这个TRRIG,然后在另一个表里(CreditInsurance )删除一条记录啊
      

  4.   

    同意楼上的说法,你现在看来只能用“in”作为检索条件进行删除,不过如果你担心会发生错误的话,可以为Deleted表定义一个游标,然后根据游标的记录指针再逐一删除流水表中数据。
      

  5.   

    问题是为什么他报错说子查询的返回记录大于一条呢? 我只删除一条记录啊,实在没道理,
    这个DELETED到底是代表什么呢?
      

  6.   

    按理说不会的。
    try:
    CREATE TRIGGER del ON dbo.CreditInsurance 
    FOR DELETE 
    AS
    set nocount on
    delete  Gatheringprawn from deleted where Gatheringprawn.insurecode = deleted.insurecode
      

  7.   

    CREATE TRIGGER del ON dbo.CreditInsurance 
    FOR DELETE 
    AS
    set nocount on
    delete from Gatheringprawn
    where insurecode in (select insurecode from deleted)
      

  8.   

    我觉得可能是你的gatheringprawn表中还有删除触发器,这个错误是它报的,你最好看一看.