Alter default SQL generated in context menu top 1000

  • 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

  • I don't believe so.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • 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

  • 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".

  • 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