SQL Server Articles

Submit Article
Home » Articles » SQL Server » Meta Data FunctionsRSS Feeds

DB_ID Function

Posted By: Sarita Patel     Category: SQL Server     Views: 5954

This article explains about DB_ID function in sql server with examples.

DB_ID function is used to get database identification number.

Syntax of DB_ID Function :

DB_ID ( [ 'database_name' ] )

database_name is a database name. It is an optional parameter. It is of type nvarchar.

Return type of DB_ID function is smallint.

Examples of DB_ID Function :

Example 1 : Use of DB_ID function to get id of database in select clause

SELECT DB_ID('Northwind')


Above example returns id for Northwind database.


Didn't find what you were looking for? Find more on DB_ID Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of DB_ID Function is from United States.
View All Articles

Related Articles and Code:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!