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

Draco picture Draco · Aug 20, 2009 · Viewed 180.5k times · Source

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

Answer

kemiller2002 picture kemiller2002 · Aug 20, 2009

FOR SQL SERVER

IF EXISTS(select * FROM sys.views where name = '')