How to determine current database | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to determine current database

It’s probably the simpliest question in the world but I can’t seem to locate the answer. Let say I logged into a SQL Server instance via osql and bounced from one database to another forty times and I’ve forgotton what database I am currently in. How do I determine what database I am currently using? Thanks,
Jethro.
Thanks for all viewers but I have found what I am looking for. declare @dbname sysname
SELECT @dbname = db_name()
print @dbname
Thank You,
Jethro
]]>