About 17,600,000 results
Open links in new tab
  1. ALTER DATABASE (Transact-SQL) - SQL Server | Microsoft Learn

    Mar 10, 2025 · Use this statement to change the name of a database, change the edition and service objective of the database, join or remove the database to or from an elastic pool, set database options, add or remove the database as a secondary in a geo-replication relationship, and set the database compatibility level.

  2. SQL Query to Rename Database - GeeksforGeeks

    Nov 27, 2024 · To rename a database in SQL, you’ll need to use the ALTER DATABASE command. The syntax varies slightly between different SQL platforms, but the core functionality remains the same. The ALTER DATABASE statement allows you to modify the properties of a database, including its name.

  3. sql server - How to change the current database in an SQL

    Feb 13, 2018 · Use a new connection to connect to a different database. I've considered turning on SQL CMD mode and using the :CONNECT command, but I don't want to connect to a different database server, just change the database.

  4. sql - How to switch database context to newly created database

    How do I switch to a SQL Server Server Database that will exist after another command?

  5. Working with the SQL Server command line (sqlcmd) - SQL Shack

    Oct 18, 2017 · The following example will set the variable DATABASENAME with the value adventureworks2014 and then we change the context to the database specified: As you can see, SETVAR is used to specify the value of the variable. Then you need to use $ () for the variable. You can list the tables of the database using the information_schema.tables view.

  6. SQL ALTER DATABASE - W3Schools

    SQL ALTER DATABASE is an essential statement to modify the properties of an existing database in a Relational Database Management System (RDBMS). This statement is helpful if you want to rename a database, change its composition, or modify file properties. The basic syntax for the ALTER DATABASE statement is as follows: Basic Syntax:

  7. sql server - How to Dynamically change the database using TSQL ...

    Sep 4, 2017 · I'm having trouble with trying to dynamically change the context of SSMS to the database specified in dynamic SQL: It executes successfully however the database context of SSMS doesn't change. I've tried a slight modification to the above like so. Again, it executes successfully, but the database doesn't change.

  8. How to change default database in SQL Server without using MS SQL

    With the MSSQL queries below, you can change database on sqlcmd: USE testdb GO Then, you can check the currently used database: SELECT DB_NAME() GO testdb. Then, you can show all the existed databases: SELECT name FROM master.sys.databases GO …

  9. SQL Server: Change current database via variable

    This can be done by means of dynamic sql. use a variable to store dbname and use this variable to build a sql string like. SELECT @Sql ='SELECT fields FROM ' + @dbname +'.Table' then use EXEC() or sp_executesql to execute the sql string.

  10. PostgreSQL: Listing and Switching Databases in psql

    Jan 27, 2023 · To switch databases in SQL Shell, the “\c” and “\connect” commands are used with the respective database name. Example 1: Switching Database Using “\c” Command. Specify the “\c” command followed by the database name to which you want to establish a connection:

  11. Some results have been removed
Refresh