"Use" command

  • Hi,

    Is anyone know that what is the behind work of "Use" function. we could use this "Use" command to change the database. Is there any other way to change the database in sql server other than the short cut key. If please let me know. If you find that info in any of the website please let me know the link..

    Thanks in advance

    Pras

  • I'm not sure what you are looking for.

    * You can use "USE" to change database by T-SQL

    * You can use your mouse to change database by select another in databases combo-box

    * You can use CTRL-U to select another database by shortcut

    * You can use SQLCMD scripts to dynamically specify database name

    Which input type is missing?

  • If you want, you can query between databases by qualifying the database objects with the db name? Is that what you're looking for? Otherwise, you have to switch databases to switch databases and the USE statement is the correct TSQL syntax for doing it.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • by default for every new connection the master database is opened and then we use "USE " to go to a particular database .

    The other way could be to change the default database of the user connecting to SQL Server to a user database .

    Regards

    Abhay Chaudhary
    Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply