IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_employees]') AND type = 'V')
DROP VIEW [dbo].[mps_employees]
GO

CREATE view [dbo].[mps_employees] as 
 
select 
a.cu_id,
a.cu_cmpid,
b.lgu_bcid cu_bcid,
b.lgu_branch  cu_branch,
b.lgu_dpid cu_dpid,
b.lgu_depart cu_depart,
a.cu_fastkey,
a.cu_code,
a.cu_account,
a.cu_star,
a.cu_gender,
a.cu_security,
a.cu_function,
a.cu_managelevel,
a.cu_professionlevel,
a.cu_otlevel,
a.cu_name,
a.cu_mobile,
a.cu_contact,
a.cu_nation,
a.cu_address,
a.cu_post,
a.cu_position,
a.cu_qq,
a.cu_identtype,
a.cu_identno,
a.cu_email,
b.lgu_otid cu_otid,
b.lgu_title cu_title,
a.cu_dpid2,
a.cu_depart2,
a.cu_otid2,
a.cu_title2,
a.cu_dpid3,
a.cu_depart3,
a.cu_otid3,
a.cu_title3,
a.cu_duty,
a.cu_party,
a.cu_origin,
a.cu_academic,
a.cu_height,
a.cu_major,
a.cu_college,
a.cu_graduate,
a.cu_degrees,
a.cu_marriage,
a.cu_entrytime,
a.cu_dimission,
a.cu_salary,
a.cu_status,
a.cu_login,
a.cu_icon,
a.cu_sign,
a.cu_birth,
a.cu_use
from mps_employee a,mps_login_role b
where a.cu_id=b.lgu_cuid