About 25,800,000 results
Open links in new tab
  1. sql - Find out current database name (MSSQL) - Stack Overflow

    Sep 15, 2022 · With the MSSQL queries below, you can check the current database: In addition, if you don't specify a database on sqlcmd, "master" database is used by default. db_name () will get you the name of database that you using. you can see the result with: select db_name()

  2. DB_NAME (Transact-SQL) - SQL Server | Microsoft Learn

    Apr 8, 2025 · Transact-SQL syntax conventions. The identification number (ID) of the database whose name DB_NAME returns. If the call to DB_NAME omits database_id, or the database_id is 0, DB_NAME returns the name of the current database. nvarchar (128)

  3. How to Find Database Name in SQL Server Using Query?

    Oct 27, 2023 · To find database names in SQL Server using query, you have two ways: first, you can find the name of the database using the database ID, or you can use a function that shows the name of the currently connected database.

  4. How To Find Database Name In SQL Server - DatabaseFAQs.com

    Dec 11, 2024 · Finding database name in SQL servers is a daily task for an SQL developer. In this article, I will guide you through multiple ways to find a database name in SQL server with some real-time examples. Let us discuss all those approaches individually. To find database name in SQL server, we can execute the query below.

  5. How to get SQL Server database name - T-SQL Tutorial

    There are two primary methods for retrieving the database name in SQL Server: using the DB_NAME () function or employing SQL Server Management Studio (SSMS). The DB_NAME() function is a built-in Transact-SQL (T-SQL) function that returns the name of the current database. It takes no parameters and simply returns the current database name.

  6. Getting the Name of the Server and Databases in SQL Server

    To find the name of the server. 1. Using sysservers. The following query gives the name of the database and the server name: Select * from sysservers. Output. 2. Using @@servername variable. Global variables are pre-defined system functions. Their names begin with an …

  7. How to Display the Database Name in the Result of a Query?

    Jan 2, 2025 · In this article, we will learn about how to display the database name in the result of a query with the help of the DB_NAME () method in SQL Server by understanding various examples and so on. What is DB_NAME () in SQL Server?

  8. Get Database Names from SQL Server - Tutorial Gateway

    Here, we will show you how to Get database names in the Server. You can also use sysdatabases to get the list of databases available in the Server. Or, use the sp_databases stored procedure to get a list of databases in the Sql Server. In this example, we will restrict the result.

  9. Get Current Database Name in SQL Server using DB_NAME

    Let's use DB_NAME () function to get current database name. As you see in below screenshot, DB_NAME () function without any database id parameter returns the current SQL database name in the select list.

  10. SQL SERVER - A Quick Note on DB_ID() and DB_NAME() - Get …

    Jan 13, 2011 · Now I know it well and have no issue but recently I see one of the DBA getting confused when looking at the DBID from one of the DMV and not able to related that directly to Database Name. Reference: Pinal Dave (https://blog.sqlauthority.com) Quite often a simple things makes experienced DBA to look for simple thing.

Refresh