Page 1 of 1

Example for check database existst and create it if not

Posted: Mon 09 Oct 2006 16:49
by alf.krause
Have you an example for connecting MS SQL Server and checking for existing database. If database not existist create the database without the directory values of SQL Server (http://crlab.com/forums/viewtopic.php?t=1350 without

ON PRIMARY
( NAME = [rgeadat],
FILENAME = 'C:\Programme\Borland\Delphi7\Projects\rgea.21\daten\rgeadat.mdf',
SIZE = 1 MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10 % )
LOG ON
( NAME = [rgealog],
FILENAME = 'C:\Programme\Borland\Delphi7\Projects\rgea.21\daten\rgealog.ldf',
SIZE = 1 MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10 % )


THX AK

Posted: Tue 10 Oct 2006 10:45
by Jackson
We have no such example.
You can connect to master database and then use following statement:
IF DB_ID (N'mytest') IS NULL
CREATE DATABASE mytest;
For more information please see MSDN.