

USE IN_LD0
GO
DROP VIEW IN_LD0.KS0V0U10
GO
DROP VIEW IN_LD0.KS0V0U13
GO
DROP VIEW IN_LD0.KS0V0U20
GO
DROP VIEW IN_LD0.KS0V0U21
GO
DROP VIEW IN_LD0.KS0V0U22
GO
DROP VIEW IN_LD0.KS0V0U23
GO
DROP VIEW IN_LD0.KS0V0U24
GO
DROP VIEW IN_LD0.KS0V0U25
GO
DROP VIEW IN_LD0.KS0V0U26
GO
DROP VIEW IN_LD0.KS0V0U27
GO

CREATE VIEW IN_LD0.KS0V0U10 as
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from AM_LD0.AM_LD0.ld0v0u10 u10, AM_LD0.AM_LD0.ld0v0z z
union all
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from PP_LD0.PP_LD0.ld0v0u10 u10, PP_LD0.PP_LD0.ld0v0z z
GO

CREATE VIEW IN_LD0.KS0V0U13 as
select u13.* from AM_LD0.AM_LD0.ld0v0u13 u13
union all
select u13.* from PP_LD0.PP_LD0.ld0v0u13 u13
GO

CREATE VIEW IN_LD0.KS0V0U20 as
select u20.* from AM_LD0.AM_LD0.ld0v0u20 u20
union all
select u20.* from PP_LD0.PP_LD0.ld0v0u20 u20
GO

CREATE VIEW IN_LD0.KS0V0U21 as
select u21.* from AM_LD0.AM_LD0.ld0v0u21 u21
union all
select u21.* from PP_LD0.PP_LD0.ld0v0u21 u21
GO

CREATE VIEW IN_LD0.KS0V0U22 as
select u22.* from AM_LD0.AM_LD0.ld0v0u22 u22
union all
select u22.* from PP_LD0.PP_LD0.ld0v0u22 u22
GO

CREATE VIEW IN_LD0.KS0V0U23 as
select u23.* from AM_LD0.AM_LD0.ld0v0u23 u23
union all
select u23.* from PP_LD0.PP_LD0.ld0v0u23 u23
GO

CREATE VIEW IN_LD0.KS0V0U24 as
select u24.* from AM_LD0.AM_LD0.ld0v0u24 u24
union all
select u24.* from PP_LD0.PP_LD0.ld0v0u24 u24
GO

CREATE VIEW IN_LD0.KS0V0U25 as
select u25.* from AM_LD0.AM_LD0.ld0v0u25 u25
union all
select u25.* from PP_LD0.PP_LD0.ld0v0u25 u25
GO

CREATE VIEW IN_LD0.KS0V0U26 as
select u26.* from AM_LD0.AM_LD0.ld0v0u26 u26
union all
select u26.* from PP_LD0.PP_LD0.ld0v0u26 u26
GO

CREATE VIEW IN_LD0.KS0V0U27 as
select u27.* from AM_LD0.AM_LD0.ld0v0u27 u27
union all
select u27.* from PP_LD0.PP_LD0.ld0v0u27 u27
GO

GRANT ALL ON IN_LD0.ks0v0u10 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u13 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u20 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u21 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u22 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u23 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u24 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u25 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u26 TO LD0ROANV
GO
GRANT ALL ON IN_LD0.ks0v0u27 TO LD0ROANV
GO

USE PP_LD0
GO

DROP VIEW PP_LD0.KS0V0U10
GO
DROP VIEW PP_LD0.KS0V0U13
GO
DROP VIEW PP_LD0.KS0V0U20
GO
DROP VIEW PP_LD0.KS0V0U21
GO
DROP VIEW PP_LD0.KS0V0U22
GO
DROP VIEW PP_LD0.KS0V0U23
GO
DROP VIEW PP_LD0.KS0V0U24
GO
DROP VIEW PP_LD0.KS0V0U25
GO
DROP VIEW PP_LD0.KS0V0U26
GO
DROP VIEW PP_LD0.KS0V0U27
GO

CREATE VIEW PP_LD0.KS0V0U10 as
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from AM_LD0.AM_LD0.ld0v0u10 u10, AM_LD0.AM_LD0.ld0v0z z
union all
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from IN_LD0.IN_LD0.ld0v0u10 u10, IN_LD0.IN_LD0.ld0v0z z
GO

CREATE VIEW PP_LD0.KS0V0U13 as
select u13.* from AM_LD0.AM_LD0.ld0v0u13 u13
union all
select u13.* from IN_LD0.IN_LD0.ld0v0u13 u13
GO

CREATE VIEW PP_LD0.KS0V0U20 as
select u20.* from AM_LD0.AM_LD0.ld0v0u20 u20
union all
select u20.* from IN_LD0.IN_LD0.ld0v0u20 u20
GO

CREATE VIEW PP_LD0.KS0V0U21 as
select u21.* from AM_LD0.AM_LD0.ld0v0u21 u21
union all
select u21.* from IN_LD0.IN_LD0.ld0v0u21 u21
GO

CREATE VIEW PP_LD0.KS0V0U22 as
select u22.* from AM_LD0.AM_LD0.ld0v0u22 u22
union all
select u22.* from IN_LD0.IN_LD0.ld0v0u22 u22
GO

CREATE VIEW PP_LD0.KS0V0U23 as
select u23.* from AM_LD0.AM_LD0.ld0v0u23 u23
union all
select u23.* from IN_LD0.IN_LD0.ld0v0u23 u23
GO

CREATE VIEW PP_LD0.KS0V0U24 as
select u24.* from AM_LD0.AM_LD0.ld0v0u24 u24
union all
select u24.* from IN_LD0.IN_LD0.ld0v0u24 u24
GO

CREATE VIEW PP_LD0.KS0V0U25 as
select u25.* from AM_LD0.AM_LD0.ld0v0u25 u25
union all
select u25.* from IN_LD0.IN_LD0.ld0v0u25 u25
GO

CREATE VIEW PP_LD0.KS0V0U26 as
select u26.* from AM_LD0.AM_LD0.ld0v0u26 u26
union all
select u26.* from IN_LD0.IN_LD0.ld0v0u26 u26
GO

CREATE VIEW PP_LD0.KS0V0U27 as
select u27.* from AM_LD0.AM_LD0.ld0v0u27 u27
union all
select u27.* from IN_LD0.IN_LD0.ld0v0u27 u27
GO

GRANT ALL ON PP_LD0.ks0v0u10 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u13 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u20 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u21 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u22 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u23 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u24 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u25 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u26 TO LD0ROANV
GO
GRANT ALL ON PP_LD0.ks0v0u27 TO LD0ROANV
GO

USE AM_LD0

DROP VIEW AM_LD0.KS0V0U10
GO
DROP VIEW AM_LD0.KS0V0U13
GO
DROP VIEW AM_LD0.KS0V0U20
GO
DROP VIEW AM_LD0.KS0V0U21
GO
DROP VIEW AM_LD0.KS0V0U22
GO
DROP VIEW AM_LD0.KS0V0U23
GO
DROP VIEW AM_LD0.KS0V0U24
GO
DROP VIEW AM_LD0.KS0V0U25
GO
DROP VIEW AM_LD0.KS0V0U26
GO
DROP VIEW AM_LD0.KS0V0U27
GO

CREATE VIEW AM_LD0.KS0V0U10 as
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from PP_LD0.PP_LD0.ld0v0u10 u10, PP_LD0.PP_LD0.ld0v0z z
union all
select u10.* , z.KUNDRFV, z.kundnamn, z.KUNDKOD from IN_LD0.IN_LD0.ld0v0u10 u10, IN_LD0.IN_LD0.ld0v0z z
GO

CREATE VIEW AM_LD0.KS0V0U13 as
select u13.* from PP_LD0.PP_LD0.ld0v0u13 u13
union all
select u13.* from IN_LD0.IN_LD0.ld0v0u13 u13
GO

CREATE VIEW AM_LD0.KS0V0U20 as
select u20.* from PP_LD0.PP_LD0.ld0v0u20 u20
union all
select u20.* from IN_LD0.IN_LD0.ld0v0u20 u20
GO

CREATE VIEW AM_LD0.KS0V0U21 as
select u21.* from PP_LD0.PP_LD0.ld0v0u21 u21
union all
select u21.* from IN_LD0.IN_LD0.ld0v0u21 u21
GO

CREATE VIEW AM_LD0.KS0V0U22 as
select u22.* from PP_LD0.PP_LD0.ld0v0u22 u22
union all
select u22.* from IN_LD0.IN_LD0.ld0v0u22 u22
GO

CREATE VIEW AM_LD0.KS0V0U23 as
select u23.* from PP_LD0.PP_LD0.ld0v0u23 u23
union all
select u23.* from IN_LD0.IN_LD0.ld0v0u23 u23
GO

CREATE VIEW AM_LD0.KS0V0U24 as
select u24.* from PP_LD0.PP_LD0.ld0v0u24 u24
union all
select u24.* from IN_LD0.IN_LD0.ld0v0u24 u24
GO

CREATE VIEW AM_LD0.KS0V0U25 as
select u25.* from PP_LD0.PP_LD0.ld0v0u25 u25
union all
select u25.* from IN_LD0.IN_LD0.ld0v0u25 u25
GO

CREATE VIEW AM_LD0.KS0V0U26 as
select u26.* from PP_LD0.PP_LD0.ld0v0u26 u26
union all
select u26.* from IN_LD0.IN_LD0.ld0v0u26 u26
GO

CREATE VIEW AM_LD0.KS0V0U27 as
select u27.* from PP_LD0.PP_LD0.ld0v0u27 u27
union all
select u27.* from IN_LD0.IN_LD0.ld0v0u27 u27
GO

GRANT ALL ON AM_LD0.ks0v0u10 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u13 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u20 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u21 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u22 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u23 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u24 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u25 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u26 TO LD0ROANV
GO
GRANT ALL ON AM_LD0.ks0v0u27 TO LD0ROANV
GO
 

