ORIGINAL_DB_NAME (Transact-SQL)

APPLIES TO: yesSQL Server (starting with 2008) noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

Returns the database name specified by the user in the database connection string. This database is specified by using the sqlcmd-d option (USE database). It can also be specified with the Open Database Connectivity (ODBC) data source expression (initial catalog =databasename).

This database is different from the default user database.

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
ORIGINAL_DB_NAME ()  

Remarks

If the initial database isn't specified, the function returns an empty string.

See Also

sqlcmd Utility
osql Utility
SQL Server Native Client (ODBC)