I have done some searching and looking out on SO, however i haven't been capable of finding much help around the matter. I'm creating an internet service which utilizes an MSSQL 2008 Server. The appropriate structure is one thing such as this... There's a primary database which houses all Primary Account/Company information (Company title, address, etc..). Additionally, you will find databases for every Account/Company which houses all the relevant (meta?)data for your account (customers, configurations, etc...).

SQL2008 Server
|-------Accounts Table
|-----------Account Record where ID = 1
|-----------Account Record where ID = 2
|-----------Account Record where ID = 3
|-------Users Table for account where ID = 1
|-------Users Table for account where ID = 2

Whenever a new account is produced (let us say, ID=3), I'm trying to puzzle out a method to clone the table schema and sights (NOT the information) of AccountDatabase0001 right into a new database known as AccountDatabase00003. I possibly could use almost any language to do the duplication as lengthy as possible known as from the PHP page in some way.

Has anybody run into this type of PHP script, or perhaps a script in almost any other such language for your matter? It is possible to command I'm able to send the the SQL server to get this done for me personally? I am i may find all things in by hand crossing the dwelling and writing SQL claims to produce each object, but I am wishing for some thing simple.

This can be done using SMO with no troublel .. Here's one site that provides specific code for this. The code is within C#, but hopefully you are able to integrate it or translate it into PHP.