SQL 2008 Select Top 1000 and update the selected database drop-down
When you right click and do a Select top 1000 rows from a table in sql 2008, it opens a tab and writes the sql and then executes it. This is okay, however I'll erase the sql and use the same tab of开发者_运维技巧ten to do other sql statements. What annoys me is that I have to go to the database drop-down at the top of the window and change it to the current database I'm in because it says Master.
How can I make sql 2008 update the selected database for this tab automatically when I right click a table and do select top 1000?
On a side note, can I automatically hide the select statement that it generates and just show grid of results?
I'd be interested in an answer to this as well, but meanwhile the workaround I've used is instead of choosing the "Select Top 100 Rows" option in the table context menu, I select the "Script Table as" -> "SELECT To" -> "New Query Window".
While this leaves off the "TOP 1000" part of the query and still fully qualifies the table name with the database and schema name, it will at least cause SQL Management Studio to set the current database to the database that contains the table.
精彩评论