ORIGINAL_DB_NAME
catalog lookup
What changes
- Input
- catalog metadata (object, column, index, file, database properties)
- Output or change
- id, name or property value
Syntax at a glance
ORIGINAL_DB_NAME ()
Work example
Inspect the original database name after a context switch.
Use schema-qualified names and test missing and permission-hidden objects separately.
Check your work Compare with DB_NAME only when diagnosing USE or module execution context.
Open Microsoft Learn for full syntax, permissions, and details for your version.