November 14, 2021 at 10:31 pm
Hi All.
When the context menu is bought up on a database table after clicking the right mouse button, you can select the top 1000 records, this is cool, but is it possible to alter the SQL generated?
Ideally I would like to be able to customise this so that the SQL always has "Order by 1 desc" appended to it as generally (not all the time) the ID field is the first column, but it is not always named "ID" so I feel this would generalise it enough to capture my needs 90% of the time.
I have hit a point where I know I can manually type every time but it is tedious
I have been doing a bit of research and cannot find anywhere that answers this question, I can see where to alter the number of records returned, and I can possibly see I could customise the menu to add my own option (but not link it to the specific table that is clicked)
Is it possible to alter the default SQL to include an order by statement?
thanks in advance
November 15, 2021 at 6:25 am
I don't believe so.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 15, 2021 at 2:17 pm
If you do this a lot, create a stored procedure or maybe a view. If nothing else, have the query in a file that you can open & run. That way you can customize exactly what you want, then save it.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
November 15, 2021 at 2:53 pm
If ID is (nearly) always an identity column, you can use ORDER BY $IDENTITY, that way you don't need to know the exact column name.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 15, 2021 at 8:43 pm
Thanks for all the suggestions, I will have a deeper dive into the stored proc option and ensure I have the $identity included...
sounds like these will get me going .
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply