Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
Co so du lieu (Thi)

Co so du lieu (Thi)

Ratings:

4.33

(1)
|Views: 296|Likes:
Published by api-3850105

More info:

Published by: api-3850105 on Oct 19, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

QU\u1ea2N L\u00dd D\u1ef0 \u00c1N
C\u00e2u 1: Vi\u1ebft Trigger \u0111b\u1ea3o m\u1ed7i nhvi\u00ean ch\u1ec9 thhi\u1ec7n 1 d.\u00e1n

Create Trigger Cau1
ON Phan_cong
FOR Insert, Update
AS
if exists (select * from Inserted where manv in (

select distinct manv from Phan_cong
)
)

Begin
Raiserror('Mot nhvien ko the thgia nhieu d.\u00e1n',16,1)
Rollback tran
End

C\u00e2u 2: Vi\u1ebft Trigger \u0111b\u1ea3o m\u1ed9t d.\u00e1n \u0111b\u1ea3o ch\u1ec9 t.\u0111a 5 nhvi\u00ean

Create Trigger Cau2
ON Phan_cong
FOR Insert, Update
AS
if exists (select * from Inserted where manv in (

select manv from Phan_cong
group by manv
having count(manv)=6

)
)

Begin
Raiserror('Mot d.\u00e1n ko th\u1ec3 qu\u00e1 5 nhvi\u00ean',16,1)
Rollback tran
End

C\u00e2u 3: Vi\u1ebft Trigger \u0111b\u1ea3o ng\u00e0y kth\u00fac lu\u00f4n >= ng\u00e0y b\u0111\u1ea7u d\u1ef1 \u00e1n

Create Trigger Cau3
ON Du_an
FOR Insert, Update
AS
if exists (select * from Inserted where ngayketthuc < ngaybatdau )
Begin
Raiserror('Loi xay ra', 16, 1)
Rollback tran
End

C\u00e2u 4: Vi\u1ebft Trigger \u0111b\u1ea3o nhvi\u00ean n\u1ebfu l\u00e0 tr\u01b0\u1edfng ph\u00f2ng th\u00ec ko \u0111c tham gia v\u00e0o bk\u00ec d.\u00e1n n\u00e0o.

Create Trigger Cau4
ON Phan_cong
FOR Insert, Update
AS
if exists (select * from Inserted where manv in (

select distinct matp from Phong_ban
)
)

Begin
Raiserror('Loi xay ra',16,1)
Rollback tran

End
C\u00e2u 5: Vi\u1ebft Trigger \u0111.b\u1ea3o m\u1ed9t d.\u00e1n ko th\u1ec3 k\u00e9o d\u00e0i qu\u00e1 10 ng\u00e0y

Create Trigger Cau5
ON Du_an
FOR Insert, Update
AS
if exists (select * from Inserted where ngayketthuc-ngaybatdau>10

)

Begin
Raiserror('Loi xay ra',16,1)
Rollback tran

End
C\u00e2u 6: Vi\u1ebft Trigger \u0111.b\u1ea3o bk\u00ec d.\u00e1n n\u00e0o c\u0169ng ph\u1ea3i c\u00f3 \u00edt nh\u1ea5t 1 tr.ph\u00f2ng thgia

Create Trigger Cau6
on Phan_cong
for Insert, Update
As
if exists (select * from Inserted where manv in (select distinct matp from Phong_ban

group by matp
having count(matp)>=1)
)begin

raiserror('loi',16,1)
rollback tran
end

C\u00e2u 7: Vi\u1ebft Trigger \u0111.b\u1ea3o khi c\u00f3 1 d.\u00e1n ch\u01b0a h.th\u00e0nh th\u00ec ko \u0111c c\u00f3 th\u00eam d.\u00e1n kh\u00e1c.

Create Trigger Cau7
ON Du_an
FOR Insert, Update
AS
if exists (select * from Inserted where ngaybatdau < any(

select ngayketthuc from Du_an
)
)

Begin
Raiserror('Loi xay ra',16,1)
Rollback tran

End
C\u00e2u 8: Vi\u1ebft Trigger \u0111.b\u1ea3o 1 nhvi\u00ean ko th\u1ec3 thgia >= 2 d.\u00e1n trong c\u00f9ng kho\u1ea3ng thgian.

create Trigger Cau8c
on Phan_cong
for Insert, Update
As

declare @count int
declare @ngay datetime
declare @ngaykt datetime

select @count =count(manv) from Inserted a, Du_an i where i.mada = a.mada and ngaybatdau

=@ngay and ngayketthuc =@ngaykt
if (@count >0)
begin
if exists (select * from Inserted where mada in (select distinct mada from Phan_cong

group by mada
having count(mada)>=2 )
)begin

raiserror('khong the mot nhan vien tham gia 2 du cung 1 khoang thoi gian',16,1)
rollback tran
end
end

C\u00e2u 9: Vi\u1ebft Trigger \u0111b\u1ea3o nh\u1eefng ng\u01b0\u1eddi thgia trong c\u00f9ng 1 d.\u00e1n ph\u1ea3i \u1edf nh\u1eefng ph\u00f2ng kh\u00e1c nhau
C\u00e2u 10: Vi\u1ebft Trigger \u0111b\u1ea3o nh\u1eefng ng\u01b0\u1eddi thgia trong c\u00f9ng 1 d.\u00e1n ph\u1ea3i \u1edf c\u00f9ng ph\u00f2ng nhau.
C\u00e2u 11: Vi\u1ebft Trigger \u0111.b\u1ea3o 1 nhvi\u00ean ko th\u1ec3 thgia >=2 d.\u00e1n trong c\u00f9ng kho\u1ea3ng th\u1eddi gian, v\u00e0 sau khi
hth\u00e0nh d.\u00e1n n\u00e0y thgia d.\u00e1n kh\u00e1c ph\u1ea3i c\u00e1ch nhau 5 ng\u00e0y.
C\u00e2u 12: Vi\u1ebft Trigger \u0111.b\u1ea3o nhvien trph\u00f2ng ph\u1ea3i thu\u1ed9c ph\u00f2ng \u0111\u00f3
C\u00e2u 13: Vi\u1ebft c\u00e2u truy v\u1ea5n li\u1ec7t k\u00ea t\u00ean nhvi\u00ean \u0111ang thgia nhi\u1ec1u h\u01a1n 1 d.\u00e1n

select tennv from Du_an a, Phan_cong b, Nhan_vien c
where a.mada = b.mada and b.manv=b.manv
group by tennv
having count(tennv)>1

C\u00e2u 14: Vi\u1ebft c\u00e2u trv\u1ea5n li\u1ec7t k\u00ea t\u00ean d.\u00e1n \u0111\u00e3 h.th\u00e0nh m\u00e0 s\u1ed1 ng\u01b0\u1eddi thgia gia d.\u00e1n n\u00e0y >= 5 v\u00e0 trong \u0111\u00f3
ko c\u00f3 trph\u00f2ng n\u00e0o.

- \u0110\u1ea7u ti\u00ean vi\u1ebft h\u00e0m tr\u1ea3 v\u1ec1 s\u1ed1 tr\u01b0\u1edfng ph\u00f2ng thgia c\u00e1c d.\u00e1n
Create function Cau14(@Ngay datetime)
returns @KQ table
(mada char(10),

tenda char(100),
sotp int
)AS

Begin
insert into @KQ(tenda,sotp)
select a.tenda, a.tenda, (

select count(b.mada) from Du_an b, Phan_cong c, Phong_ban d where b.mada=c.mada
and c.manv=d.matp and b.mada=a.mada
group by b.mada

)
from Du_an a
update @KQ set sotp=0 where sotp is null
return
End
- Vi\u1ebft c\u00e2u trv\u1ea5n

Activity (6)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
kaigan05 liked this
khamle0964192 liked this
nguoidatinh liked this
Thang Hoa Tat liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->