DB_NAME

Description

This function returns the name of a specified database.(DB_NAME in Transact-SQL).

Sample Source Pattern

Syntax

IN -> SqlServer_01.sql
DB_NAME ( [ database_id ] )  

Examples

Code:

IN -> SqlServer_02.sql
SELECT DB_NAME();

Result:

RESULT             |
-------------------+
ADVENTUREWORKS2019 |

Known issues

1. CURRENT_DATABASE function has different behavior in certain cases

DB_NAME function can be invoked with the database_id parameter, which returns the name of the specified database. Without parameters, the function returns the current database name. However, SnowFlake does not support this parameter and the CURRENT_DATABASE function will always return the current database name.

  1. SSC-FDM-TS0010: CURRENT_DATABASE function has different behavior in certain cases.

Last updated