Example for check database existst and create it if not

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
alf.krause
Posts: 7
Joined: Wed 20 Sep 2006 09:44

Example for check database existst and create it if not

Post by alf.krause » Mon 09 Oct 2006 16:49

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

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Tue 10 Oct 2006 10:45

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.

Post Reply