Custom SSMS Shortcuts for ETL Developer. Part 1: SELECT in a Keystroke

  • As others have mentioned, I have CTRL+0 set up as "SELECT * FROM", Yes, I know it's bad using SELECT * but picking 50 is arbitrary and I usually need to see more rows. Besides, this is only in our DEV environment that I use this.

    As far as working for other schemas, mine works fine as long as I highlight the schema name with the table name. So to select all rows from the person.person table, I would highlight "person.person" and then hit CTRL+0. Easy as pie.

    In fact, I get so used to it that I find myself "CTRL+0'ing" in our production environment and wondering why I get no rows back...lol



    I am Melvis.

  • Matt Wright (9/22/2011)


    As others have mentioned, I have CTRL+0 set up as "SELECT * FROM", Yes, I know it's bad using SELECT * but picking 50 is arbitrary and I usually need to see more rows. Besides, this is only in our DEV environment that I use this.

    As far as working for other schemas, mine works fine as long as I highlight the schema name with the table name. So to select all rows from the person.person table, I would highlight "person.person" and then hit CTRL+0. Easy as pie.

    In fact, I get so used to it that I find myself "CTRL+0'ing" in our production environment and wondering why I get no rows back...lol

    Lovely!

    Could you please put me through this.I think I have not get it right. I ran the s procedure on against Production.Product, set up the shortcut keys and then press the keys afterward. All I got was error. Below is how I did it:

    CREATE PROCEDURE dbo.sp_select

    @product NVARCHAR(200)

    AS

    DECLARE @cmd NVARCHAR(255)

    SET @cmd ='SELECT TOP 50 * from '+ @product

    EXEC sp_executesql @cmd

    GO

    Production.Product --This (Production.Product) was then highlighted. But I got this error:

    Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near '.'.

    Please give details.

    Thanks!

  • SaintGr8 (9/22/2011)


    Matt Wright (9/22/2011)


    As others have mentioned, I have CTRL+0 set up as "SELECT * FROM", Yes, I know it's bad using SELECT * but picking 50 is arbitrary and I usually need to see more rows. Besides, this is only in our DEV environment that I use this.

    As far as working for other schemas, mine works fine as long as I highlight the schema name with the table name. So to select all rows from the person.person table, I would highlight "person.person" and then hit CTRL+0. Easy as pie.

    In fact, I get so used to it that I find myself "CTRL+0'ing" in our production environment and wondering why I get no rows back...lol

    Lovely!

    Could you please put me through this.I think I have not get it right. I ran the s procedure on against Production.Product, set up the shortcut keys and then press the keys afterward. All I got was error. Below is how I did it:

    CREATE PROCEDURE dbo.sp_select

    @product NVARCHAR(200)

    AS

    DECLARE @cmd NVARCHAR(255)

    SET @cmd ='SELECT TOP 50 * from '+ @product

    EXEC sp_executesql @cmd

    GO

    Production.Product --This (Production.Product) was then highlighted. But I got this error:

    Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near '.'.

    Please give details.

    Thanks!

    I never used the sp_select stored proc, so I can't comment on it's functionality. That's why I use the actual query "SELECT * FROM" as my keyboard shortcut query. Have you tried that? Then it works in any database you are connected to regardless of if you remember to create the sp_select proc in that database.

    If you want the TOP 50, then enter in your keyboard shortcut query as "SELECT TOP 50 * FROM" (without the quotes of course).



    I am Melvis.

  • No! I will do that right now. That mean that I can highlight any schema and table name in a database and hit the keys.

    Thanks for the help.

  • SaintGr8 (9/22/2011)


    That mean that I can highlight any schema and table name in a database and hit the keys.

    That's exactly how it works for me.

    Thanks for the help.

    Glad to be of assistance...



    I am Melvis.

  • Done and dusted!

    Thanks a lot.

  • SELECT * FROM works fine, thanks

  • Thanks you all for the comments!

    Great idea to use SQL Select statement directly for Query Shortcut. I use more than one stored procedure for my keyboard shortcuts and therefore keep the settings identical; other SPs are lengthier than this Select (please read my two other articles next week). But I agree for this simple and most often used operation it'd be the best to assign its SQL statement directly for a shortcut.

    To apply keyboard shortcuts to any DB schema, include delimited identifiers to enclose full table name including special characters such as dot, for example:

    'Production.Product' or

    "Production.Product" or

    [Production.Product]

    Olga Klimova
    BI Consultant, MCITP
    www.returnonintelligence.ca

  • Is there a shortcut to actually paste "select * from " or whatever value you need? So all you would have to do is enter your shortcut then followed by the table_name?

    For example, if my keyboard shortcut was "select * from", then I can just go to it and it'll enter "select * from " on my query window and all I have to do is type the table_name. Much like a copy/paste action.

  • Right, I got it, using the following sintax for the table name:

    [font="Courier New"][Production.Product][/font]

    But I had never tried it before because it is wrong.

  • Carlo Romagnano (9/22/2011)


    shayk (9/22/2011)


    Nice, but the SP unnecessary. You can write in the SSMS "Select TOP 50 * FROM "

    I also use this "Select TOP 50 * FROM ". It is better than sp, because if you connect to another server, maybe that the stored proc doesn't exist.

    I wonder how much you can put in the shortcut. I'm not sure you'd want to but could you have a CTE in there?

    Ken

  • ken.trock (9/22/2011)


    Carlo Romagnano (9/22/2011)


    shayk (9/22/2011)


    Nice, but the SP unnecessary. You can write in the SSMS "Select TOP 50 * FROM "

    I also use this "Select TOP 50 * FROM ". It is better than sp, because if you connect to another server, maybe that the stored proc doesn't exist.

    I wonder how much you can put in the shortcut. I'm not sure you'd want to but could you have a CTE in there?

    Ken

    Here is my current list:

    1 sp_who

    2 sp_lock

    3 sp_who2

    4 sp_spaceused

    5 sp_monitor

    6 sp_tables

    7 sp_columns

    8 sp_stored_procedures

    9 sp_helptext

    0 select * from

    Some require a highlighted parameter, others don't. Play around with them...



    I am Melvis.

  • If you want to increase your profienciency I would also suggest using a clipboard manager. I've been using arsClip for more years than I can remember now and it will save you countless hours.

    As for SSMS, while I'm sure your approach speeds you up slightly, I think you should spend the money and get SQL Prompt and SQL Search from Redgate. I'm quick but those tools changed my life and made me super fast.

  • Here is my current list:

    1 sp_who

    2 sp_lock

    3 sp_who2

    4 sp_spaceused

    5 sp_monitor

    6 sp_tables

    7 sp_columns

    8 sp_stored_procedures

    9 sp_helptext

    0 select * from

    Some require a highlighted parameter, others don't. Play around with them...

    That last one is cool; makes the call flexible.

    Ken

  • I would also highly recommend the SSMS Tools Pack[/url]. It does this with ~30 common snippets initially, and does a lot more. Best of all it is free and highly maintained. A great find that I have used on my dev machine ever since I found it 6 months ago.

    shayk (9/22/2011)


    Nice, but the SP unnecessary. You can write in the SSMS "Select TOP 50 * FROM "

Viewing 15 posts - 16 through 30 (of 34 total)

You must be logged in to reply to this topic. Login to reply