2017-11-11 279 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

相关问题