建立或替換檢視
此查詢將刪除檢視(如果已存在)並建立一個新檢視。
IF OBJECT_ID('dbo.PersonsView', 'V') IS NOT NULL
DROP VIEW dbo.PersonsView
GO
CREATE VIEW dbo.PersonsView
AS
SELECT
name,
address
FROM persons;
此查詢將刪除檢視(如果已存在)並建立一個新檢視。
IF OBJECT_ID('dbo.PersonsView', 'V') IS NOT NULL
DROP VIEW dbo.PersonsView
GO
CREATE VIEW dbo.PersonsView
AS
SELECT
name,
address
FROM persons;