Home
How To ...
Trouble shooting
 

Cry How to...

Determine the name of the database you are connected to


To get the name of the current database:

select db_name(dbid) from master..sysprocesses where spid=@@SPID

alternately:

sp_who @@SPID

will give the name of the current database and other information about the current user.


These notes have been tested against SQL Server 7 and SQL Server 2000.