tags:

views:

28

answers:

2

I use around 3 sql server 2008 databases. everytime I need to query on a database, I need to login to that db and then qery. is there a way to retain the last opened database in sql server 2008?

as an analogy, think this is like firefox allowing to display the last open websites.

A: 

You would need to have the same login for all 3 databases and have auto_close set to off

SQLMenace
auto_close doesn't affect whether or not you need to login to the database. Rather, it clears up resources that would otherwise be used by keeping the database open when there are no active sessions.
Jeremy Smyth
But it *does* affect whether you *can* login to it.
RBarryYoung
+1  A: 

SQL Server retains last opened database. It actually never closes them (auto_close and user instances not withstanding). Do you mean Management Studio by any chance? You can add an USE statement to your saved query. You can use sqlcmd extensions in your query to simply run the query in one shot on all servers/db. Or you can use something like SSMS Tools Pack, a free add on that enhances SSMS with things like query history.

Remus Rusanu