Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If OBJECT_ID('usp_Cau11','p') is not null
- drop proc usp_Cau11
- go
- create proc usp_Cau11
- @mapm char(10),
- @ngaymuon date
- as
- if not exists(select * from PhieuMuon where mapm= @mapm) return 1
- Update PhieuMuon
- set ngaymuon = @ngaymuon
- where mapm= @mapm
- update ctpt
- set tienphat =
- ctpt.mucgiaphat*(DATEDIFF(DD,pm.ngaymuon, pt.ngaytra)*-ctpm.songayquydinh)
- 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)
- where pm.mapm = @mapm
- if @@ROWCOUNT >0 return 0
- go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement