hckr.fyi // thoughts

Change the Query for Editing Top 200 Rows in SQL Server Management Studio

by Michael Szul on

SQL Server Management Studio (SSMS) is a one of those professional tools that Microsoft stack developers simply can't live without. It's probably the best SQL workbench on the market, and MS is always known for giving a lot of love to its developers through great tools.

When quickly examining data in database table, it's not uncommon for developers to use two context menu entries: "Select Top 1000 Rows" and "Edit Top 200 Rows." Usually, the first is used as a starting point for data analysis, and constructing more complex queries. Why hand-type that when SSMS will start it off for you? The second is used to quickly edit one or more records without having to write update statements.

What happens, however, when there are more than 200 rows, and you can't get at the data you need through that simple context menu? Easy. You can alter the selection criteria of that result set.

Right-click on any database table and choose "Edit Top 200 Rows." In the results pane, right-click on any record, select "Pane," then select "SQL." This will bring up the SQL pane over the results pane, as if you just executed a standard select query from a new query window. You can then edit the query in the top pane, execute it, and the results that appear in the bottom pane remain editable just like the original "Edit Top 200 Rows" results.