Alex Rivera | Logout

How can I check if a View exists in a Database?

Asked 2009-08-20T12:54:41.887
158

I have some SQL code that needs to be executed if a certain View exists in a database. How would I go about checking if the View exists?

EDIT: The DBMS being used is Microsoft SQL Server

Edit
Report

2 Answers

192

FOR SQL SERVER

IF EXISTS(select * FROM sys.views where name = '')
answered 2009-08-20T12:57:17.927
1

if it's Oracle you would use the "all_views" table.

It really depends on your dbms.

answered 2009-08-20T12:59:53.357

Your Answer