About 16,900,000 results
Open links in new tab
  1. Using name of a database inside a sql script for a full table name

    Nov 7, 2011 · How to correctly use a database name in sql scripts to keep code neutral to a specific database? Code just for an illustration: DELETE FROM [MyDatabase].[dbo].[MyTable] …

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

    Apr 8, 2025 · This function returns the name of a specified database. Transact-SQL syntax conventions. Syntax DB_NAME ( [ database_id ] ) Arguments database_id. The identification …

  3. SQL Select Database - GeeksforGeeks

    Apr 28, 2025 · Let’s take a look at how to select a database in SQL, using MySQL as an example. Suppose you have a database called company_db that contains employee information. 1. …

  4. How to display the database name in the result of a query?

    Jan 14, 2024 · You can use the DB_NAME () function to fetch the name of the current database as an additional column. DB_NAME() AS [dbName]; I've actually used that DB_NAME function …

  5. SQL - SELECT Database, USE Statement - Online Tutorials Library

    Following is the syntax of the USE DATABASE statement in SQL −. USE DatabaseName; Here, the DatabaseName is the name of the database that we want to select. The database name is …

  6. sql server - Using variable for database name - Database

    Jul 13, 2015 · You can put above select statement in a variable and do and EXEC and save it in a .sql file and then use sqlcmd to just directly call that .sql file and run it on multiple servers.

  7. Assign a database name into the variable via SQL in SQL server

    Aug 20, 2018 · You can try the following query. DECLARE @DBname VARCHAR(MAX) DECLARE @SQL VARCHAR(MAX) SET @DBname = 'PatientTurningSystem' SET @SQL = …

  8. Make databasename / schema a variable in select statement

    Sep 10, 2008 · You can do this with dynamic SQL like: DECLARE @query VARCHAR(MAX) DECLARE @CONNECTION VARCHAR(50) SELECT @CONNECTION = 'SOMEDATABASE' …

  9. 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 …

  10. Use Server name with database - Microsoft Q&A

    Dec 1, 2020 · It is up to the client application or tool to connect to the desired server before executing USE. SSMS (in SQLCMD mode) and the SQLCMD utility provide a CONNECT …

  11. Some results have been removed
Refresh