Shortcut to avoid typing something

  • Hi guys,

    I can't count how many times I have to type "SELECT * FROM" in the Management Studio Editor.

    Is there a way to setup the Management Studio Editor (or maybe the Windows) to bring a text when I push a sequence of Shortcut.

    Something like this: When I push CTRL-Shift-S then the text "SELECT * FROM" will be inserted in my editor.

    Thanks,

    Luiz.

  • Time to pitch a Red-Gate product:

    http://www.red-gate.com/products/SQL_Prompt/index.htm

    You get some intellisense as well as shortcuts for frequently types "phrases".

  • [font="Courier New"]Hi Luiz,

    You can go for SQL 2008 client tools where Microsoft have incorporated the above feature. 🙂

    [/font]

  • Thank you for your answers.

    Is there a way to do it through Windows?

    Luiz.

  • In SQL Server Management Studio:

    Tools -> Options -> Environment -> Keyboard

    -Eddie

    Eddie Wuerch
    MCM: SQL

  • Eddie Wuerch (4/8/2008)


    In SQL Server Management Studio:

    Tools -> Options -> Environment -> Keyboard

    -Eddie

    Eddie,

    Your suggestion allows me to execute execute something using a shortcut.

    What I want is to insert a text in the Mgmt Studio Editor.

    Well, a second thought: your idea may work if it is possible to include a command that copy a text to clipboard and then past it back to the editor. Something like this:

    sp_copyToclipboard 'select * from'

    sp_PastFromclipboard

    Does anybody know if there is a command or proc that copies something to clipboard ?

    Luiz.

  • Clipmate, the clipboard-extender program I use, does that. You can evaluate it for 30 days, but then you'd have to buy the program.

  • SELECT * FROM

    Lets see. That took less than 2 seconds. CTRL>SHIFT>S ? Maybe a little quicker.

    What I need is something to automatically correct the dyslexic version that I frequently end up with:

    SELECT * FORM

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • Proably is overkill for "SELECT * FROM"

    I use SQLServer Management Studio templates for things like:

    SELECT c.Description as Clinic, a.ApptDate,

    p.NameLast + ', ' +

    COALESCE(p.NameFirst,'') + ' ' +

    COALESCE(p.NameMiddle,'') + ' ' +

    COALESCE(p.NameSuffix,'') + ' ' +

    COALESCE(p.NamePrefix,'') AS PatientName,

    CASE

    WHEN MissedAppt = 'Y' THEN 'No Show'

    WHEN MissedAppt = 'S' THEN 'Show'

    WHEN Cancelled = 'Y' THEN 'Cancel'

    ELSE '--' END as Disposition

    FROM Appointment a INNER JOIN Clinic c

    ON a.ClinicSID = c.ClinicSID

    INNER JOIN Patient p

    ON a.PatientSID = p.PatientSID

    (got tired of typing the COALESCEs - takes me 3 tries to type it right, every time.)

    It's a drag & drop rather than a hot-key but it comes with SSMS.

  • Well, I see that it's not only me who has problems with "SELECT * FORM" and COALESCE.

    It seems that Mgmt Studio still doesn't offer a solution for (the not only) my problem.

    But as was pointed earlier, a third part solution, such as Clipmate, can help me.

    Does anybody know one that is free?

    Thanks,

    Luiz.

  • Perhaps you could try AutoHotKey. It seems like it would have what you are looking for and it is free. I have not used this personally but a friend of mine uses it alot for all different things, such as auto filling login info when developing as well as SQL syntax.

    Personally, I have used SQL Prompt by RedGate and like that alot. But, it does cost money.

    John

  • Thanks, John.

    I installed Autohotkey and it solved my problem.

    Luiz.

  • There is a fairly short method of inserting any text you want into the editor. Within the Management Studio I have a 5 keystroke sequence setup that also does the trick.

    First you will need to customize the toolbar by adding a tool found in the 'Edit' subcategory called 'Insert File'. To make this item keyboard accessible simply give it a new name with the '&'. ex: 'In&sert File' will allow the command to be triggered using the {S} key after hitting {ALT}.

    Next you would create a file containing your text. I found that saving the file as a .sql filetype made it easier to find plus I gave it a short name as 's.sql'. As long as you have this file saved in the folder that your insert file dialog box opens up with then you're all set.

    From here it's a quick key sequence of {ALT}, {S}, {ENTER}, {S}, {ENTER}. And waulla! your code comes strolling in. The aspect I like with this solution is there are no key combos and every key can be hit without taking your fingers off the home keys.

    Autohotkey may be just what the doctor ordered. But it never hurts to have a backup plan.:cool:

    Thanks,

    Jody

  • Another alternative for people who like to type as little as possible:

    Try ctrl+shift+Q, which brings up the query designer (in SSMS) using the database of the current connection. Then select a table and close the table selector. Then select all columns or individual columns and click OK. The query is now in a regular query tab/window.

    That may sound like a lot of work, but it's easier than typing:

    SELECT system_monthly_summary_trustIXeligibility.*

    FROM system_monthly_summary_trustIXeligibility

  • Luiz (4/30/2008)


    Thanks, John.

    I installed Autohotkey and it solved my problem.

    Luiz.

    Your welcome. The benefits from this program is that it can be used in other applications. 🙂

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

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