We have moved some servers which had ArcGIS application and SDE on it to another server and the IP has changed. Now when I want to open my .mxd file it tries to connect to remote SDE with old connection settings and opening old works but really takes long time, consequently I want to change my database connection in .mxd file.

Is there any fast way to change SDE settings programmatically with not opening the .mxd file in ArcMap?

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Users\arc\Desktop\election2011.mxd")
brklist = arcpy.mapping.ListBrokenDataSources(mxd)
print brklist

Above code really takes along time. without this code i can open my .mxd file with same time above code and can change manually...

  • 2
    I had the same issue recently, but the slow opening was due to too many SDE connections at the time, which resolved itself. However, it would have been very useful to redirect the layers to source an alternative ArcSDE geodatabase by running a Python script if only the Python script did not have to instantiate the mxd first.
    – PolyGeo
    Commented Jul 21, 2011 at 1:53
  • do u have any example code for this? thnk u
    – urcm
    Commented Jul 21, 2011 at 6:51
  • 1
    Sorry Aragon - because at 10.0 it takes forever to get the MXD open when its ArcSDE Connection has issues there seemed no point me writing code. It sounds like 10.1 will open that up as an option. In the meantime I think your best bet for example code, which would need to be run in advance of trying to open the maps with "broken" connections, is at help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/…
    – PolyGeo
    Commented Jul 21, 2011 at 7:12
  • thnk u. if your sde is on remote machine , will we use the same method? mxd.findAndReplaceWorkspacePaths(r"C:\Project\Connection to Default.sde", r"C:\Project\Connection to Version1.sde") C:\Project\Connection to Version1.sde ?
    – urcm
    Commented Jul 21, 2011 at 14:09
  • 1
    I think that as long as your second SDE Connection file references the remote machine then that should work. I've not tested this personally.
    – PolyGeo
    Commented Jul 21, 2011 at 22:35

2 Answers 2


We had this same problem with really sucks. The MXD tries for 15 minutes to find the old server before giving up. We got around this problem by giving a new server the old SDE server's IP address. The new server has nothing to do with GIS or databases. However, the MXD tries to connect then gives up right away once it sees that the SDE data source is no longer there. The MXD opens quickly with the broken layer icons so you can fix the data source on your own.


It looks like the answer to this one is No at ArcGIS 10.0, and Yes at ArcGIS 10.1 which appears likely to contain an ArcPy solution. For more information see the ArcGIS Idea called Deal with broken datasources in an MXD better

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.