Get current DBName in use of the users connection?

  • for example:

    USE pubs

    GO

    /* Now is there a T-SQL statement to return which databasename I am currently using, i.e. this would return 'pubs' in this situation

    */

    -- and I do

    USE Northwind

    go

    -- run the same T-SQL and it should return 'Northwind'.

    is this possible? any answers would be appreciated.

    thank you.

  • Select DB_Name()

  • Select DB_ID(),DB_Name()

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply