-- MS SQL 沒有ORACLE 的 CREATE OR REPLACE 功能
-- 建議在 CREATE 前加下面的判斷,如果存在就刪除
IF EXISTS (SELECT 1
FROM sysobjects
WHERE id = object_id('VW_HOME)
AND type = 'V')
DROP VIEW VW_HOME
GO
-- CREATE VIEW
CREATE VIEW VW_HOME
AS
(
SELECT
T1.IDNO IDNO,
T2.NAME NAME,
T1.ROLE COLLATE Chinese_PRC_CS_AS PROD_CATE ROLE
FROM FAMILY T1
LEFT JOIN PEOPLE T2 ON T2.IDNO = T1.IDNO
)