Hi,
is it possible to create a new SQL Server database using SDAC?
How?
Cheers
Geza
Is it possible to create a new database?
Re: Is it possible to create a new database?
SDAC doe not have a method for creating a database. You can try creating a database with the following SQL query:
CREATE DATABASE [NewDBName]
For example, to create a database with the name 'database_name', that does not exist on the server:
CREATE DATABASE [NewDBName]
For example, to create a database with the name 'database_name', that does not exist on the server:
Code: Select all
const
DBName: 'database_name';
...
MSConnection1.Database := 'master';
MSConnection1.Connect;
MSConnection1.ExecSQL(
' IF (DB_ID(N' + QuotedStr(DBName) + ') IS NULL) ' +
' BEGIN' +
' CREATE DATABASE [' + DBName + '] ' +
' END;');
MSConnection1.Disconnect;
//connect to [database_name]
MSConnection1.Database := DBName;
MSConnection1.Connect;