MS SQL Server Concepts and Programming Question:
Download Job Interview Questions and Answers PDF
How To See Existing Views in MS SQL Server?
Answer:
If you want to know how many views you have created in a database, you use the system view called sys.views to get a list of views defined in the current database. The tutorial exercise shows you how many views in database GlobalGuideLineDatabase:
USE GlobalGuideLineDatabase;
GO
CREATE VIEW ggl_links_view AS
SELECT * FROM ggl_links;
GO
SELECT * FROM sys.views;
GO
<pre>name object_id schema_id type type_desc
--------------- ----------- ---------- ---- ----------
ggl_links_view 1189579276 1 V VIEW
ggl_links_top 1205579333 1 V VIEW
(2 row(s) affected)</pre>
USE GlobalGuideLineDatabase;
GO
CREATE VIEW ggl_links_view AS
SELECT * FROM ggl_links;
GO
SELECT * FROM sys.views;
GO
<pre>name object_id schema_id type type_desc
--------------- ----------- ---------- ---- ----------
ggl_links_view 1189579276 1 V VIEW
ggl_links_top 1205579333 1 V VIEW
(2 row(s) affected)</pre>
Download MS SQL Server Interview Questions And Answers
PDF
Previous Question | Next Question |
How To Create a View on an Existing Table in MS SQL Server? | How To Drop Existing Views from a Database in MS SQL Server? |