July 4, 2008 at 8:39 am
I have several databases to select from and each time I have to use the drop down menu to select the database I need. Is there any way of declaring which database I want to use without using the drop down menu?
July 4, 2008 at 8:49 am
You can put a use statement in the script.
Use database1
go
Select statment
Use database2
go
Select statement
July 4, 2008 at 10:42 am
Just qualify the database in the FROM clause.
SELECT Col1, Col2
FROM TestDB1.dbo.MyTable
SELECT Col5, Col10, Col7
FROM DifferentDB.dbo.AnotherTable
Run the queries and you'll be querying the databases without the need to change the database manually or use the USE syntax.
July 4, 2008 at 11:25 am
You can also create a shortcut to Query Analyzer that will automatically connect to a specific server and database. The command line is:
isqlw.exe -S
You can also add -E for Integrated Security or "-U -P" to hard code a login and password.
SQL = Scarcely Qualifies as a Language
July 4, 2008 at 11:27 am
The command line was truncated:
isqlw.exe -S SqlServerName -D DatabaseName
SQL = Scarcely Qualifies as a Language
February 11, 2011 at 11:26 am
You can always change your default database to one you use the most...
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply