-- ============================================
-- 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.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.