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)

Syntax

'Declaration
Public Shared Function CreateUnattachedContentDatabase ( _
    databaseInstanceServer As String, _
    databaseName As String, _
    username As String, _
    password As String _
) As SPContentDatabase
'Usage
Dim databaseInstanceServer As String
Dim databaseName As String
Dim username As String
Dim password As String
Dim returnValue As SPContentDatabase

returnValue = SPContentDatabase.CreateUnattachedContentDatabase(databaseInstanceServer, _
    databaseName, username, password)
public static SPContentDatabase CreateUnattachedContentDatabase(
    string databaseInstanceServer,
    string databaseName,
    string username,
    string password
)

Parameters

  • databaseInstanceServer
    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.

  • username
    Type: System.String

    The user name that will login to the database.

Return value

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

Remarks

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.

See also

Reference

SPContentDatabase class

SPContentDatabase members

CreateUnattachedContentDatabase overload

Microsoft.SharePoint.Administration namespace

Other resources

Fine-grained Data Restoration from Unattached Database