0
我遇到问题:我试图完全更新SQL Server 2012中的临时表(在存储过程中),但它只更新与我的描述相匹配的第一个条目。下面是代码:完全更新临时表SQL
create table #t (store_name varchar(30),
product_name varchar(30),
price int,
valab_since date,
valab_until date,
best_offer varchar(3))
--some code that populates my table
update #t set best_offer = 'yes'
where price = (select min(price) from Cataloage as c
INNER JOIN Produse as p
on c.codP = p.codP
where p.denumire = #t.store_name)
update #t set best_offer = 'no'
where price > (select min(price) from Cataloage as c
INNER JOIN Produse as p
on c.codP = p.codP
where p.denumire = #t.product_name)
select * from #t
Cataloage
和Produse
是一些表,我使用。
感谢您的及时回复。我不得不做一些小的修改,但基本上它做到了。 – 2013-05-13 20:20:17