Showing posts with label MetaData Function. Show all posts
Showing posts with label MetaData Function. Show all posts

Friday, 1 April 2016

How to find the database Name in SQL Server ?

In a Single SQL Server Instance ,it is possible to have multiple databases.
Each database has its own unique ID.

If you know the database ID then
refer the following syntax 

Syntax:

DB_NAME('Database ID')

Example:

SELECT DB_NAME(5)

Output:

Sample


For the ID : 5 the Name of the database is Sample.

Tuesday, 29 March 2016

How to get the ID of the selected database in SQL server ?

To get the ID of the selected database refer the following syntax 

Syntax:

DB_ID()

Example:

SELECT DB_ID()

Output:

5

Open a new query window ,select the required database and Now execute the above function,then you will get the ID of the selected database.

How to get the database ID in SQL Server ?

In a Single SQL Server Instance ,it is possible to have multiple databases.
Each database has its own unique ID.

To get the ID of the database refer the following syntax 

Syntax:

DB_ID('Database Name')

Example:

SELECT DB_ID('Sample')

Output:

5

Now the ID of the Sample database is 5.