When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

The SQL Guru Answers your Questions...


Today's question comes from SPG:

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 or an ASP page. 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 statement actually has a number of parameters that you can set to customize your database creation. A more involved example follows:

CREATE DATABASE USER8
ON
(NAME = 'User8_dat',
 FILENAME = 'c:\mssql7\data\User8dat.mdf',
 SIZE = 10,
 MAXSIZE = 50,
 FILEGROWTH = 5 )
LOG ON
(NAME = 'User8_log',
 FILENAME = 'c:\mssql7\data\User8log.ldf',
 SIZE = 2MB,
 MAXSIZE = 25MB,
 FILEGROWTH = 5MB )

This example provides more detail on the creation of the database. We are naming both the data file and the log file explicitly. The NAME and FILENAME allow us to assign a logical and physical file name to both the data file (ON) and log file (LOG ON). The SIZE allows us to set the initial size for the data file and log file. We use the MAXSIZE to specificy the maximum size of the file and FILEGROWTH to set the increments by which the database will grow.

All numbers will default to megabytes (MB) unless we say otherwise. You can see in the LOG ON clause I specified MB. You could also ues KB if you wanted a small database. This would probably only be useful when SQL Server 2000 comes out for the Pocket PC.

You can get even more complicated when you create databases but this is enough for now. Check SQL Server Books Online for details. I hope this is a faboo as you were expecting!

  • Answered by SQLGuru graz - SQLTeam.com


    Read Other SQL Guru Questions


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES