Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Creating a Site Collection in a New Content Database

Posted by ken zheng on October 10, 2008

There are two methods of getting around this. In the first method, the administrator goes to all Content Databases (SharePoint Central Admin – Application Management Tab – Content Databases) and takes the databases ‘offline’. Note that simply taking the databases offline does not affect user functionality; it only dissallows new Sites from being created in the specific Content Database. Once all Content Databases except for the one desired are taken offline, creating a new Site Collection will force that Site Collection to be created in the one you want.

If the databases aren’t created in advance, there is an even easier way to do this, by using the –createsiteinnewdb flag with the STSADM tool. The STSADM tool (located on web front-ends in the \program files\common files\microsoft shared\web server extensions\12\bin folder) is a fantastic administrative tool that performs a myriad of administration with SharePoint. In this case, it allows you to create a new Site Collection within a new Content Database. The following Syntax illustrates one example:

stsadm -o createsiteinnewdb -url http://docs.companyabc.com/dept/hr -owneremail SharePoint@companyabc.com -ownerlogin COMPANYABC\SPAdmin -sitetemplate sts -title “Human Resources” -databaseserver SERVER1 -databasename “HR-Content-DB”

In this example, a new site collection is created at the URL http://docs.companyabc.com/dept/hr. The Site Collection Owner is set to COMPANYABC\Spadmin and the Site Collection owner email is set to SharePoint@companyabc.com. The default team site template is used to create the site (the template is simply named ‘sts’, without the quotes.) The database server is SERVER1 and the name of the database created is HR-Content-DB.

Using this concept, you can construct a SharePoint environment that will scale quite nicely, as content is distributed across multiple databases. In addition, If you need to scale to multiple database servers, it simply involves moving content databases to the new server and updating the location in SharePoint.

7 Responses to “Creating a Site Collection in a New Content Database”

  1. AutoSponge said

    Actually, WSS databases are “self-leveling” like water. If you create a new content database, it has 0 sites. The next site collection you create will go there.

    If you have 3 sites in one DB and 1 in another, the next site created will go into the DB with 1 (making it 3-2).

    The other rule that applies, if you have 3-0-0 for sites in 3 DBs, the oldest DB with 0 will get the next site.

    No need for stsadm if you plan ahead.

  2. ken zheng said

    You are exactly right, I just want to let people know you can manually control the site collection to the content database

  3. Ken, I’ve posted an supplementary overview of creating site and subsites in new content databases.
    You can find it there http://msmvps.com/blogs/laflour/archive/2008/10/15/tips-to-create-a-site-collection-in-new-content-database.aspx

  4. ken zheng said

    Thanks Michael, it is a good article.

  5. Just one question.

    Is-it possible to specify at the creation of a new collection site database the location of the content database files ?

    For instance, I would like to create 2 Collection Sites on the same SQL Server. But for the first one, content database files have to be on drive X, and for the second one, content database file have to be on drive Y.

    Thanks a lot for your help.

    • ken zheng said

      This should be configured in your SQL, you can create the content database then set up driver in your SQL Management Studio

  6. Alex said

    Hey Jerome,
    The best option is to precreate the databases before running the stsadm command. make sure the dbs are empty and have the correct collation.
    the opther option is to create them on the fly, then detach, move and reattach the database.

    Alex

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>