Productivity Keyboard Shortcuts 2

  • Comments posted to this topic are about the item Productivity Keyboard Shortcuts 2

  • I think We can Directly Add like this

    Tools >> Options >> Environment > Keyboard

    no need to Create SP-Script it will work

    Alt+F1 Sp_Help

    Ctrl+F1 Sp_HelpText

    Ctrl+1 Sp_Who

    Ctrl+2 Sp_Lock

    Ctrl+3 Select * FROM

    Ctrl+4 Select Top 100 * From

    please correct me if i am wrong

  • You could, but you won't have that much flexibility and you can send many parameters to stored procedure, for example you want to search for an object that contains "product" in the name but you want the search to return only procedures (you need 2 parameters), type "#product#, P" highlight it and press CTRL+5 and there you have it.

    Or you want to do a "SELECT TOP 1000..." but you want to order it by a specific column, let’s say price, but from the highest to lowest value, just write "SomeTable, Price#" highlight it and press CTRL+3

    Personally I find it very helpful to navigate through a database just by using those shortcuts and works for me very well and for my colleges, it took them a little time to get used to it but once they did they won't work without it anymore..

  • I thought this was a great idea, but in trying it I get incorrect syntax errors. I'm not sure what I'm doing wrong - I added the commands into the options dialog, ran the script and restarted SSMS. I do see the two new sprocs in master...

    Any ideas?

    Thanks

  • Double check you entry in keyboard shortcuts settings from step 3, make sure you leave comma at the end, give me am example what would you like to do.

  • Thanks for the great script.

  • Kutang Pan (7/13/2015)


    Double check you entry in keyboard shortcuts settings from step 3, make sure you leave comma at the end, give me am example what would you like to do.

    That's exactly what it was - the comma. I must have been careless with my cut/paste.

    Nice job, thanks.

  • Any suggestions about the functionality and future enhancements highly appreciated! :hehe:

  • Kutang Pan (7/13/2015)


    Any suggestions about the functionality and future enhancements highly appreciated! :hehe:

    Well, I don't know how you'd get around it, but it would be nice if the shortcut opened a new query and ran there. As it stands, we need to type things like parameters and '%' after column names, then run. That's a little painful because we have to do it right in the code we're working on, or copy paste manually into a new window.

  • Agree with % being painful to add while working... Was thinking to add it for ctrl 5 8 9 as default on bith sides

  • Not sure how this is supposed to work

    I tried highlighting a table name in Object Explorer and pressing [Ctrl] 9 but get nothing

    Tried dragging table name onto new query page, highlight name and press [Ctrl] 9 but get syntax error

    keyboard code is:

    DECLARE @DB NVARCHAR(500) SET @DB = DB_NAME() EXEC master.dbo.Shortcuts 9, @DB,

    When I paste the code and than put my table name in the command it works well but not the keyboard shortcut...?

    DECLARE @DB NVARCHAR(500) SET @DB = DB_NAME() EXEC master.dbo.Shortcuts 9, @DB, '[dbo].[profiles]'

    TIA

    Tom in Sacramento - For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • not in object explorer, in query window while writing code, the whole purpose of it is to keep your hands on keyboard

  • I have feedback regarding Ctrl-0 to search for a phrase in an object's script. I have something I've been running to do that as well, but it uses sys.sql_modules instead of sys.comments:

    use MyDatabase

    go

    select distinct db_name(), o.name

    from sys.sql_modules m (nolock)

    inner join sys.objects o (nolock) on m.object_id = o.object_id

    where m.definition like '%SomeText%'

    The comment I incorporated at the top of the script explains why:

    -- Use sys.sql_modules because all the procedure's contents are stored

    -- in one row. syscomments only holds a maximum of 8000 characters

    -- and will split the code into multiple rows if it goes over 8000

    -- and your search string may get split in the process.

    Just sharing in case you had any thoughts?

    - Lisa

  • LSAdvantage (7/13/2015)


    I have feedback regarding Ctrl-0 to search for a phrase in an object's script. I have something I've been running to do that as well, but it uses sys.sql_modules instead of sys.comments:

    use MyDatabase

    go

    select distinct db_name(), o.name

    from sys.sql_modules m (nolock)

    inner join sys.objects o (nolock) on m.object_id = o.object_id

    where m.definition like '%SomeText%'

    The comment I incorporated at the top of the script explains why:

    -- Use sys.sql_modules because all the procedure's contents are stored

    -- in one row. syscomments only holds a maximum of 8000 characters

    -- and will split the code into multiple rows if it goes over 8000

    -- and your search string may get split in the process.

    Just sharing in case you had any thoughts?

    - Lisa

    Thank you lisa i will look into int

  • Remember you just have to highlight a piece of code, no need to open new query window

Viewing 15 posts - 1 through 15 (of 27 total)

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