By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,627 Members | 1,870 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,627 IT Pros & Developers. It's quick & easy.

verify if database exists

P: n/a
Hi,

Is there a simple way to verify if a database exists?
I'm writing a stored procedure that will accept a database name as an input
parameter,
and create the database if it does't already exist.

--
Message posted via http://www.sqlmonster.com
Nov 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Tim
IF DB_ID('dbname') IS NULL
print 'missing'
else
print 'exists'

Tim S

Nov 23 '05 #2

P: n/a
Got it. Thanks.

Tim wrote:
IF DB_ID('dbname') IS NULL
print 'missing'
else
print 'exists'

Tim S


--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...neral/200511/1
Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.