实现和下面相同功能,但不能使用with,因为with是一个关键字
with f as (select * from up_def where price_id='1' and e_dd>=getdate()) select * into #xs_price from f t where not exists(select 1 from f where prd_no=t.prd_no and sys_date>t.sys_date)
with f as (select * from up_def where price_id='1' and e_dd>=getdate()) select * into #xs_price from f t where not exists(select 1 from f where prd_no=t.prd_no and sys_date>t.sys_date)
where not exists(select 1 from #f where prd_no=t.prd_no and sys_date>t.sys_date)drop table #f
select * from up_def where price_id='1' and e_dd>=getdate()
and not exists(select 1 from f where prd_no=t.prd_no and sys_date>t.sys_date)
select * into #xs_price from f t
where not exists(select 1 from
(select * from up_def where price_id='1' and e_dd>=getdate()) t
where prd_no=t.prd_no and sys_date>t.sys_date)
select
*
into
#xs_price
from
#f t
where
not exists(select 1 from #f where prd_no=t.prd_no and sys_date>t.sys_date)
drop table #f
你在你的语句前面加个分号,就不会报错了
如果你硬是要不用cte而重新搞了一条语句实现的,当我没说