Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine whether database exists via stored proc

Status
Not open for further replies.

MattDavies51

Programmer
Oct 13, 2002
24
GB
From a stored procedure, I am looking at the best way of determining whether another database exists on that same server.

e.g. Say I'm executing a stored proc in the EngDatabase, and want to discover if a GerDatabase exists I want something like:

if exists(GerDatabase)
begin
...
else
...


I have come across the sp_databases stored proc in the Master DB, but it's not exactly what I am after.

Any help will be greatly appreciated.
Matt
 
if exists (select * from master..sysdatabases where name = 'GerDatabase' )

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top