How to check for the existence of a DB?

前端 未结 8 2219
Happy的楠姐
Happy的楠姐 2020-12-18 05:52

I am wondering if there is an elegant way to check for the existence of a DB? In brief, how do test the connection of a db connection string?

Thanks

8条回答
  •  盖世英雄少女心
    2020-12-18 06:40

    you can get list of Database with below and check your db name:

    USE master
    GO  
    SELECT name, database_id, create_date  
    FROM sys.databases ;  
    GO
    

提交回复
热议问题