星空网 > 软件开发 > 数据库

SQLServer 触发器

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='否'


 if exists(select 1 from inserted)
  BEGIN
  select @SaleShop=SaleShop from inserted
  select @minDfJjSale=min(DfJjSale),@maxDfJjSale=max(DfJjSale) from Tab_SaleAndCarStyle where Saleshop=@Saleshop and state>0 and price_ver=1 group by SaleShop
      if(@minDfJjSale=0 and @maxDfJjSale=0)
   set @isDfjj='否'
   else
   set @isDfjj='是'
   update dbo.TAB_PARTNER  
   set PriceRange=ltrim(@minDfJjSale)+'~'+ltrim(@maxDfJjSale),ispartneraddprice=@isDfjj
   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 Saleshop=@Saleshop and state>0 and price_ver=1 group by SaleShop
   if(@minDfJjSale=0 and @maxDfJjSale=0)
   set @isDfjj='否'
   else
   set @isDfjj='是'
   update dbo.TAB_PARTNER  
   set PriceRange=ltrim(@minDfJjSale)+'~'+ltrim(@maxDfJjSale),ispartneraddprice=@isDfjj
   where ID= @saleshop
  END




原标题:SQLServer 触发器

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

卖家如何利用Instagram进行站外推广?:https://www.ikjzd.com/articles/4503
海卖助手9月28日停用,两款功能强大的替代工具介绍!:https://www.ikjzd.com/articles/4507
中美贸易战波及亚马逊?看行业巨头如何回应……:https://www.ikjzd.com/articles/451
亚马逊小红旗再出没,然而此次受害者居然是亚马逊自己?:https://www.ikjzd.com/articles/4510
姚明昔日NBA队友,可口可乐曾为其提供股份,但被他拒绝了!:https://www.ikjzd.com/articles/4512
下半年亚马逊促销节假日大盘点!:https://www.ikjzd.com/articles/4513
上海滑雪场门票价格?:https://www.vstour.cn/a/408235.html
德国有那些品牌公司:https://www.vstour.cn/a/408236.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流