Custom Search
My Zimbio

Thursday, November 18, 2010

MSSQL - Use database

Query analyzer.
The first step in writing any query is ensuring you are in the right database.  If you are connected to the correct server and know which database you want to connect to use the following statement to ensure you are in the correct database.

Syntax:
Use databasename
Go

Example
Use pubs
Go

Execute the statement by hitting F5 or the execute button in the query analyzer window. After executing the statement you should see the database name in the explorer window change to the database you keyed. 

Give it a try. 

No comments:

Post a Comment