with temp as(

select *From tb_order where Auditing=2 and AuditingTime>='2013-04-01' and Flag=2
)
select *from temp where EbayAccountID=21

  

相当于临时表 temp 分析器可以智能提示 临时表却不能。

 临时表

select * into #temp From tb_order where Auditing=2 and AuditingTime>='2013-04-01' and Flag=2

select * From #temp where EbayAccountID=21

  

declare @flag int=2;
with temp as(

select *From tb_order where Auditing=2 and AuditingTime>='2013-04-01' and Flag=@flag
)
select *from temp where EbayAccountID=21

  

declare @flag int=2; 这里的分号不可少 否则会报错
关键字 'with' 附近有语法错误。如果此语句是公用表表达式、xmlnamespaces 子句或者更改跟踪上下文子句,那么前一个语句必须以分号结尾。

相关文章:

  • 2021-09-29
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-06-19
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2022-03-03
  • 2021-09-21
  • 2021-12-08
  • 2022-02-07
相关资源
相似解决方案