Error: Error: Invalid database name (-162) when running the sdesetupmssql executable

Error Message

When a database containing data still registered with ArcSDE is manually dropped from the ArcSDE/SQL Server instance, the following error is displayed:

"Error: Invalid database name (-162)"


This means that there are orphaned records in the SDE_* or GDB_* Repository tables. These repository tables contain records that are referencing feature classes in a database that no longer exists.

Solution or Workaround

  • Manually delete the affected rows from all of the SDE_* & GDB_* Repository tables before attempting to run the sdesetupmssql -o upgrade command again.
  • Re-create the database that is missing, create some dummy tables in the newly created database to reflect the names of these orphaned records in the SDE & GDB_* Repository tables.

    Use ArcCatalog to delete the data in this database which will in-turn cleanup all the records in the SDE_* and GDB_* Repository tables.

    Run the sdesetupmssql -o upgrade command again.
  • Restore a last known backup to a point in time before the database was manually deleted and then run the sdesetupmssql -o upgrade command again.