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

前端 未结 10 1696
无人共我
无人共我 2021-01-31 07:00

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 Mic

10条回答
  •  悲哀的现实
    2021-01-31 07:27

    For people checking the existence to drop View use this

    From SQL Server 2016 CTP3 you can use new DIE statements instead of big IF wrappers

    syntax

    DROP VIEW [ IF EXISTS ] [ schema_name . ] view_name [ ...,n ] [ ; ]

    Query :

    DROP VIEW IF EXISTS view_name
    

    More info here

提交回复
热议问题