Hi Randy,
Here is my code
import arcpy
arcpy.env.workspace = r"Database Connections\Connection to SVTHCPHDW.sde"
arcpy.CreateDatabaseView_management("Database Connections\Connection to SVTHCPHDW.sde","Testagain","SELECT TOP (1000) [K_And_FW_key] ,[zip] ,[Shape] ,[GeographyBaseline] ,[Year] ,[geography_key] ,[DP05_0033] ,[DP05_33E_EstNote] ,[DP05_33E_Est] ,[DP05_33E_ErrMgn] ,[DP05_33E_ErrMgnNote] ,[DP05_33PE_Pct] ,[DP05_33PE_PctNote] ,[DP05_33PE_PctErrMgn] ,[DP05_33PE_PctErrMgnNote] ,[DP05_0034] ,[DP05_34E_EstNote] ,[DP05_34E_Est] ,[DP05_34E_ErrMgn] ,[DP05_34E_ErrMgnNote] ,[DP05_34PE_Pct] ,[DP05_34PE_PctNote] ,[DP05_34PE_PctErrMgn] ,[DP05_34PE_PctErrMgnNote] ,[DP05_0035] ,[DP05_35E_EstNote] ,[DP05_35E_Est] ,[DP05_35E_ErrMgn] ,[DP05_35E_ErrMgnNote] ,[DP05_35PE_Pct] ,[DP05_35PE_PctNote] ,[DP05_35PE_PctErrMgn] ,[DP05_35PE_PctErrMgnNote] FROM [DWAcs].[rpt].[Pivot_ZipCode_Acs5DP05_GISTest]")
print "view created sucessfully"
inTable = r"Database Connections\Connection to SVTHCPHDW.sde\Testagain"
oid_field = "OID"
inTable = r"Database Connections\Connection to SVTHCPHDW.sde\Testagain"
oid_field = "K_And_FW_key"
shape_field = "Shape"
geometry_type = "POLYGON"
sr = arcpy.SpatialReference(4326)
in_extent = ""
arcpy.RegisterWithGeodatabase_management(inTable, oid_field, shape_field,
geometry_type, sr, in_extent)
mxd = arcpy.mapping.MapDocument("CURRENT")//This one is creating error
I don't have mxd file previously saved in location. Need to save it after I registered the view with Geo Database.(on fly)