programming.torensma.net: Code Snippets

SQL-server: Get current database name

It can sometimes be handy to know in which database you are working. To get the name of the current database you can use a simple script:

SELECT DB_NAME() AS DataBaseName

Resultset:

DatabaseName
------------------------
NorthWind

(1 row(s) affected)

You can follow any responses to this entry through the RSS 2.0 feed.