2017-11-11 109 views

回答

1

我想你可能想要的代碼看起來像這樣:

begin 
    declare @tbl TABLE (
      Item int 
    ); 

    insert into @tbl(Item) 
     select cid 
     from tbl_custumer 
     where cus_ph like '%'+'987'+'%'; 

    select * 
    from @tbl; 
end; 

注意事項:

  • begin/end塊是不是真的有必要,但我猜你想爲其他原因(存儲過程,if,或類似的東西)。
  • 使用insert . . . select時,不需要values關鍵字。
  • 在每個SQL語句的末尾使用分號。雖然它們是可選的,但它們使代碼更容易遵循。
+0

這是解決thanx先生 – sam5808

相關問題