Hi

How do I check whether a database exists before attaching a database
Thankx in Advance
Priya

RE: check database exists by anonymous

anonymous
Tue Apr 27 08:31:07 CDT 2004

H

-- ============================================
-- Basic Create Database Templat
-- ============================================
IF EXISTS (SELECT *
FROM master..sysdatabases
WHERE name = N'<database_name, sysname, test_db>'
DROP DATABASE <database_name, sysname, test_db
G

CREATE DATABASE <database_name, sysname, test_db
G

HT
Ravikanth[MVP]

Re: check database exists by Patrice

Patrice
Tue Apr 27 08:33:56 CDT 2004

What is your need ? In most cases, I would say the app connects and just
check for errors. Else you could have an option that browse for a mdb dfile
so that the user can connect the app to an existing and user selected
database (or use SQL DMO depending on which DBMS you are based).

Patrice


"Priya" <anonymous@discussions.microsoft.com> a écrit dans le message de
news:1688343E-AE7B-41F8-B1F6-00CBE5538163@microsoft.com...
> Hi,
>
> How do I check whether a database exists before attaching a database ?
> Thankx in Advance.
> Priya



Re: check database exists by Cor

Cor
Tue Apr 27 08:42:33 CDT 2004

Hi Priya,

What kind of datatase?

Cor



Re: check database exists by CT

CT
Tue Apr 27 08:27:10 CDT 2004

What type of database are we talking about here?

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Priya" <anonymous@discussions.microsoft.com> wrote in message
news:1688343E-AE7B-41F8-B1F6-00CBE5538163@microsoft.com...
> Hi,
>
> How do I check whether a database exists before attaching a database ?
> Thankx in Advance.
> Priya



Re: check database exists by William

William
Tue Apr 27 09:01:44 CDT 2004

That totally depends on the Db. Since you mention 'attach', I'm guessing you
mean SQL Server. In Master, there's a table called SysDatabases and a
field called Name, it has all of the databases in it, you can query using
Exists or Count(*) or whatever you wish.
"Priya" <anonymous@discussions.microsoft.com> wrote in message
news:1688343E-AE7B-41F8-B1F6-00CBE5538163@microsoft.com...
> Hi,
>
> How do I check whether a database exists before attaching a database ?
> Thankx in Advance.
> Priya