篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MS SQL简单视图相关的知识,希望对你有一定的参考价值。
IF OBJECT_ID ('dbo.vTop5Products', 'view') IS NOT NULL
DROP VIEW dbo.vTop5Products ;
-- CREATE : Create new view
-- ALTER : Alter existing view
CREATE VIEW dbo.vTop5Products
AS
SELECT TOP 5 ProductID,
Name,
ProductNumber,
StandardCost,
ListPrice
FROM Production.Product
ORDER BY ModifiedDate DESC;
GO
-- Usage
SELECT ProductID, Name FROM vTop5Products;
-- WHERE Clause
SELECT ProductID, Name
FROM vTop5Products
WHERE ProductNumber like 'BE%';