Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to find whether a database already exists in s

Author  Topic 

saurabh122
Starting Member

16 Posts

Posted - 2009-03-09 : 05:28:16
is there any way in sql server 2005 to how to find whether a database already exists

matty
Posting Yak Master

161 Posts

Posted - 2009-03-09 : 05:31:33
SELECT * FROM sys.databases WHERE name ='yourdbname'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-09 : 05:53:43

if db_id('yourdbname') is not null
print 'exists'
else
print 'doesnt exist'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -