Using VBScript to make a new SQL Server DatabaseBy Bill Graziano on 2 August 2000 | Tags: Queries SPG writes "My question is, Given that I can automate user creation with ADSI, table creation with SQL commands via ADO, and basic template web page creation with the FileSystemObject... Can I make a whole new database in SQL Server to complete the process? I've got a wide base of unrelated users, so -- even though they use similar web applications -- I'm keeping their data in separate databases. Being able to finish off new user creation automation would be faboo."
I'll give you the Transact-SQL commands to create a database and you can put them into a VBScript. It shouldn't be hard. You can create a database using the CREATE DATABASE command. For example, you might want to create a database for user2. The syntax would be:
CREATE DATABASE USER2 This is the simplest form of the create database. This actually takes the Model database and makes a copy of it naming it USER2. Therefore, any objects you create in model will appear in any new database you create. Also, any settings in model will be inherited by each new database. If you are creating multiple databases on the fly (like an ISP might) I'd recommend tuning the settings in Model to be just what you want. Especially the SELECT INTO/BULK COPY option and the file growth attributes. In order to create a database, you must be a memeber of the sysadmin or dbcreator server role.The CREATE DATABASE actually has a number of parameters that you can set to customize your database creation. A more involved example follows: CREATE DATABASE USER8
|
- Advertisement - |