Detach Database (Production Mapping)

License Level:BasicStandardAdvanced

Summary

Detaches a SQL Server Express geodatabase (.mdf).

Removes all references to the geodatabase from the database server. It does not delete the data file (.mdf). Once detached, you can attach the data file to another SQL Server Express instance.

Usage

Syntax

DetachDatabase_production (workspace)
ParameterExplanationData Type
workspace

The geodatabase to detach from an instance of SQL Server Express.

Workspace

Code Sample

DetachDatabase example (stand-alone script)

The following stand-alone script demonstrates how to use the DetachDatabase tool.

# Name: DetachDatabase_Example.py
# Description: Detaches a geodatabase (.mdf file) from an instance of SQL Server Express
# Requirements: Production Mapping extension

# import arcpy and checkout a Production Mapping license
import arcpy
arcpy.CheckOutExtension("foundation")

# local variable for the workspace parameter
gds_workspace = "Database Servers\\YOURSERVER_SQLEXPRESS.gds\\ProductLibrary (VERSION:DBO.DEFAULT)"

# detach the geodatabase from the SQL Server Express instance
arcpy.DetachDatabase_production(gds_workspace)

print "Script completed successfully."

# Check in the extension
arcpy.CheckInExtension("foundation")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Requires Production Mapping
ArcGIS for Desktop Advanced: Requires Production Mapping
6/12/2015