decalre @custid int
SELECT @custid=cust_id
  FROM t_account
  WHERE acct_number =@account_id
go
delete from t_customer
where cust_id=@custid
go

解决方案 »

  1.   

    你也可以用一条语条完成
    declare @account_id intdelete from t_customer 
    where cust_id in (select custid from t_account where acct_number=@account_id)
      

  2.   

    这样啊,呵呵。SQL SERVER 中没有SELECT INTO吗,有的话语法怎样
      

  3.   

    SELECT @cust_id=cust_id
      FROM t_account
      WHERE acct_number =@account_id
      

  4.   

    把从一个或多个表的查询结果放在一新表中
    select f1, f1
    into NewTable
    from table把查询结果写入另一个已经存在的表中
    INSERT INTO archivetitles 
       (title_id, title, type, pub_id)
    SELECT title_id, title, type, pub_id
    FROM titles
    WHERE (pub_id = '0766')
      

  5.   

    declare @custid varchar(10)
      SELECT @custid = cust_id  FROM t_account
      WHERE acct_number =@account_id  DELETE FROM t_customer   WHERE cust_id = @custid当然可以一句搞定
    delete t_customer where cust_id = (select cust_id from t_account where acct_number = @account_id)