ALTER TRIGGER [dbo]. [Pricerange]
on [dbo]. [Tab_saleandcarstyle]
For Update,insert,delete
As
declare @Saleshop int, @minDfJjSale decimal (18,3), @maxDfJjSale decimal (18,3), @isDfjj varchar (50)
Set @isDfjj = ' No '
if exists (select 1 from inserted)
begin
select @SaleShop =saleshop from Inserted
select @minDfJjSale =min (dfjjsale), @maxDfJjSale =max (Dfjjsale) from Tab_saleandcarstyle where [Email protected] and state>0 and Price_ver=1 Group by Saleshop
& Nbsp;if (@minDfJjSale =0 and @maxDfJjSale =0)
set @isDfjj = ' no '
else
set @isDfjj = ' is '
update dbo. TAB_PARTNER &NBSP,
set Pricerange=ltrim (@minDfJjSale) + ' ~ ' +ltrim (@maxDfJjSale), [email protected]
where id= @saleshop
end
Else
if exists (select 1 from deleted)
BEGIN
Select @SaleShop =saleshop from deleted
Select @minDfJjSale =min (dfjjsale), @maxDfJjSale =max (Dfjjsale) from Tab_saleandcarstyle where [email protected] and State>0 and Price_ver=1 GROUP by Saleshop
if (@minDfJjSale =0 and @maxDfJjSale =0)
Set @isDfjj = ' No '
Else
Set @isDfjj = ' Yes '
UPDATE dbo. Tab_partner
Set Pricerange=ltrim (@minDfJjSale) + ' ~ ' +ltrim (@maxDfJjSale), [email protected]
where id= @saleshop
END
SQL Server trigger----and delete trigger, two tables