Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.58 KB | None | 0 0
  1. If OBJECT_ID('usp_Cau11','p') is not null
  2.     drop proc usp_Cau11
  3. go
  4. create proc usp_Cau11
  5. @mapm char(10),
  6. @ngaymuon date
  7. as
  8.     if not exists(select * from PhieuMuon where mapm= @mapm) return 1
  9.    
  10.     Update PhieuMuon
  11.     set ngaymuon = @ngaymuon
  12.     where mapm= @mapm
  13.  
  14.     update ctpt
  15.     set tienphat =
  16.          ctpt.mucgiaphat*(DATEDIFF(DD,pm.ngaymuon, pt.ngaytra)*-ctpm.songayquydinh)
  17.     from PhieuMuon pm join PhieuTra pt on (pm.mapm = pt.mapm) join CT_PhieuTra ctpt on (pt.mapt= ctpt.mapt) join CT_PhieuMuon ctpm on (ctpm.mapm= pm.mapm)
  18.     where pm.mapm = @mapm
  19.  
  20.     if @@ROWCOUNT >0 return 0
  21. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement