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

前端 未结 10 1839
无人共我
无人共我 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:29

    if exists (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MyTable]') )
    

提交回复
热议问题