-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecZaBrisanjeReg.sql
53 lines (40 loc) · 2.43 KB
/
ecZaBrisanjeReg.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
ALTER VIEW BrisanjeNeaktivnihArtikala_ZaProgramere
AS
-- --za brisanje
SELECT proid, Naziv
--DELETE
FROM Reg WHERE TipArtikla = 1
and ProID NOT IN ( SELECT distinct proid FROM(
SELECT distinct proid
FROM [Prokontik13].[dbo].[UlazIzlazDetalj]
where vid in (select vid from ulazizlaz where dtid in (30001,40001)) and
Kol<>0 and Cena<>0
--Kol+Cena<>0
UNION ALL
SELECT distinct proid
FROM [Prokontik13].[dbo].[UlazIzlazDetalj]
where vid not in (select vid from ulazizlaz where dtid in (30001,40001))
) a )
and ProID NOT IN ( SELECT distinct proidmat FROM dbo.Normativ )
and ProID NOT IN ( SELECT distinct proidpro FROM dbo.Normativ )
/*
-- BRISANJE ZAVISNIH TABELA
select * --delete
from normativ
where proidpro not in (select proid from reg)
select * --delete
from normativ
where proidmat not in (select proid from reg)
select * -- delete
from ulazizlazdetalj
where proid not in (select proid from reg)
select * -- delete
from pro
where proid not in (select proid from reg)
select * -- delete
from BarCod
where proid not in (select proid from reg)
select * -- delete
from dbo.RegExtra
where proid not in (select proid from reg)
*/