I SQL Server Books Online er beskrevet hvordan en database oprettes med SQL–DMO objektet „Database“.
Citat:
To create a SQL Server database
- Create a Database object.
- Set the Name property of the Database object.
- Create a DBFile object.
- Set the Name property of the DBFile object.
- Set the PhysicalName property of the DBFile object.
- Set DBFile object properties optional for new database files, such as Size.
- Add the DBFile object to the new Database object FileGroup object named PRIMARY.
- Add the Database object to the Databases collection of a connected SQLServer object.
If you do not set the Size property of the DBFile object or specify a transaction log file, SQL Server defaults are used. For more information, see CREATE DATABASE.
You can specify a transaction log file during SQL Server database creation. Specify the log file prior to adding the Database object to the Databases collection.
To specify a log file
- Create a LogFile object.
- Set the Name property.
- Set the PhysicalName property.
- Set the LogFile Size property.
- Add the LogFile object to the LogFiles collection of the TransactionLog object of the new Database object.
Note! The Database object is compatible with instances of SQL Server 2000 and SQL Server version 7.0. However, the Database2 object extends the functionality of the Database object for use with features that are new in SQL Server 2000.
Script eksempel på vejledningen fra BOL:
ToDo...
Se også:
SQLDMO.Database2