Articles → SQL SERVER → Views for data abstraction
Views for data abstraction
customer_id | customer_name | customer_address |
| | |
order_id | customer_id | order_details |
| | |
payment_id | order_id | payment_details |
| | |
create procedure sp_get_customer_information
As
begin
select customer_id, customer_name, customer_address from tbl_customer_information
end
create procedure sp_get_monthly_reports
As
begin
select ci.customer_id, ci.customer_name, ci.customer_address, co.order_details
from tbl_customer_information ci inner join tbl_customer_orders co
on ci.customer_id = co.customer_id
end
create view v_customer_information
as
select customer_first_name,customer_last_name,customer_city,customer_state from tbl_customer_information
create procedure sp_get_monthly_reports
As
begin
select ci.*, co.order_details
from v_customer_information ci inner join tbl_customer_orders co
on ci.customer_id = co.customer_id
end