Check if table exists in SQL Server

前端 未结 28 2057
梦如初夏
梦如初夏 2020-11-22 04:23

I would like this to be the ultimate discussion on how to check if a table exists in SQL Server 2000/2005 using SQL Statements.

When you Google for the answer, you g

28条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 05:06

    consider in one database you have a table t1. you want to run script on other Database like - if t1 exist then do nothing else create t1. To do this open visual studio and do the following:

    Right click on t1, then Script table as, then DROP and Create To, then New Query Editor

    you will find your desired query. But before executing that script don't forget to comment out the drop statement in the query as you don't want to create new one if there is already one.

    Thanks

提交回复
热议问题