-- ============================================
-- 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
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).
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.