Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL - Create MSSQL DB

Author  Topic 

hebbs1
Starting Member

1 Post

Posted - 2005-10-31 : 03:41:47
Hi all,

I am writing an application that is required to create specific Databases on the fly.

I am coding with PHP and have no troubles in creating DB's, example code as follows:


//Create new DB
$create_db = "CREATE DATABASE " . $_POST['name'] . "
ON
( NAME = " . $_POST['name'] . "_dat, FILENAME = 'c:\program files\microsoft sql server\mssql\data\\" . $_POST['name'] . ".mdf SIZE = 10,MAXSIZE = 50,FILEGROWTH = 5 )
LOG ON
( NAME = " . $_POST['name'] . "_log, FILENAME = 'c:\program files\microsoft sql server\mssql\data\\" . $_POST['name'] . ".ldf',
SIZE = 5MB,MAXSIZE = 25MB,FILEGROWTH = 5MB )";

The problem occurs when I try to view the database through a third party application (MSSQL Manager), it wont appear until its registered.

Therein lies my problem, how to register the database via code or scripts.

Am I even on the right track here?

Regards

Hebbs

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-31 : 03:47:22
>>I am writing an application that is required to create specific Databases on the fly.

Why do you want to create Database on the fly?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -