Is there any way to get version of a layer loaded using arcpy.MakeFeatureLayer_management in arcpy with mssql server connection. There are tools that be used for several types of version related tasks like arcpy.ChangeVersion_management, arcpy.CreateVersionedView_management etc. but i want to know is there any way to know version of the that temporary layer in arcpy.

I tried Listing ArcSDE versions using ArcPy? but it gives all the version in a sde connection- but i want to know specifically with which version layer is loaded.So i do not want arcpy.ListVersions(r'Database Connections\MSSQLSERVER.sde')

I tried arcpy.Describe but all in vain.

Below is the pseudocode-


Above line does not change the version to "DBO.Test1" if i run as above but if i run the gui tool it works perfectly so i need to check if version changed.

mywrk = r"path\Test1.sde"
fc_cor1 = r'path\Test1.sde\sde__my.DBO.FIPS2900\sde__my.DBO.testfc_1'
fc_cor2 = r'path\Test1.sde\sde__my.DBO.FIPS2900\sde__my.DBO.testfc'


Now i want to know if version of 'fc1' and 'fc2' is DBO.Test1 otherwise change as below-



I am using ArcGIS 10.1 and MSSQL Server 2012


You need to obtain the map layer object first -

fl = arcpy.MakeFeatureLayer_management(fc,"out_fl")
map_layer = fl.getOutput(0)
>>> u'sde.DEFAULT'

which has the serviceProperties property - a dictionary containing all the information related to the connection including, but not limited to the version name.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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