SPContentDatabase.CreateUnattachedContentDatabase Method (String, String, String, String)

Creates a content database object, by using the specified connection information, without registering it in the configuration database of the farm.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

public static SPContentDatabase CreateUnattachedContentDatabase(
	string databaseInstanceServer,
	string databaseName,
	string username,
	string password


Type: System.String

The name of the database instance, such as Server/Microsoft##SSEEMirror, not the name of the physical server that is hosting it.

Type: System.String

The name of the database.

Type: System.String

The user name that will login to the database.

Type: System.String

The password of the user.

Return Value

Type: Microsoft.SharePoint.Administration.SPContentDatabase
The content database.

Typically, unattached content databases are used for data recovery scenarios and to get orphaned site collections and sites.

If SQL authentication is not being used, then username and password can be a null reference (Nothing in Visual Basic) or empty strings.