create trigger mytr on country 
for delete
as 
update smt_companyinfor set countrynewid=1 where countrynewid=(select id from deleted)我的意思是只要删除country中的一条记录,表smt_companyinfor 对应的项就设置为1,请问这样写法可有问题,还有就是delete后的表的ID会发生变化,,,我where的ID是准确的么? 请高手能解答解答谢谢...

解决方案 »

  1.   

    update smt_companyinfor set countrynewid=1 where countrynewid in (select id from deleted)
      

  2.   

    update a 
    set countrynewid=1 
    from smt_companyinfor a ,deleted b
    where a.countrynewid = b.id
      

  3.   

    update smt_companyinfor set countrynewid=1 where countrynewid=(select id from deleted)你的语句只能是删除一条纪录的时候,如果是多条纪录  select id from deleted 这条语句返回的是一个记录集,而等号不能匹配纪录集,要用in