ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Detach Database

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

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

  • The .mdf file and the full-text catalog for the database are in the directory in which you initially created the geodatabase.

  • When copying a detached geodatabase to another server, you do not need to copy the .ldf file. The Attach Database tool creates a new .ldf. You must copy the full-text catalog with the database (.mdf). For SQL Server 2008 Express, the full-text catalog is in the .mdf file. For the full-text catalog to transfer properly, the database server to which you move the geodatabase must also be set up to use SQL Server Full-Text Search.

  • The geodatabase must not be in use by another process during detach.

  • You must have Server Administrator privileges to detach a geodatabase.

Syntax

arcpy.production.DetachDatabase(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

  • Current Workspace

Licensing information

  • Basic: No
  • Standard: Requires Production Mapping
  • Advanced: Requires Production Mapping

Related topics

  • An overview of the Product Library toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal