Home > Archive > Microsoft SQL Server forum > November 2005 > verify if database exists









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author verify if database exists
Cismail via SQLMonster.com

2005-11-18, 11:23 am

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.webservertalk.com
Tim

2005-11-18, 11:23 am

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

Tim S

Cismail via SQLMonster.com

2005-11-18, 11:23 am

Got it. Thanks.

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


--
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Fo...eneral/200511/1
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com