Shortcut/Autocomplete in SQL Server Management Studio (SSMS)

Asked

Viewed 362 times

1

I’m using the SQL Server Management Studio (SSMS) in version 17.5 of 2017 and would like to create some shortcuts/autocomplete to make the search process a little faster, without deploying it in any application, more for the issue of using SSMS.

It would be something like typing: @slc and auto complete to select * from or simply a @join and auto complete to select * from tbl1 t1 inner join tbl2 t2 on t1.id = t2.id

Is there any way to create a shortcut or autocomplete for this case? How?

1 answer

0

You can create an XML template with the code you want to automate, and import the snippet through the "Tools" menu - "Code snippet manager..."

Here is an example template, the query goes inside the CDATA[] available in the "Snippet] node":

<?xml version="1.0" encoding="utf-8" ?>  
<CodeSnippets  xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">  
<_locDefinition xmlns="urn:locstudio">  
    <_locDefault _loc="locNone" />  
    <_locTag _loc="locData">Title</_locTag>  
    <_locTag _loc="locData">Description</_locTag>  
    <_locTag _loc="locData">Author</_locTag>  
    <_locTag _loc="locData">ToolTip</_locTag>  
   <_locTag _loc="locData">Default</_locTag>  
</_locDefinition>  
<CodeSnippet Format="1.0.0">  
<Header>  
<Title>TryCatch</Title>  
<Shortcut></Shortcut>  
<Description>Example Snippet for Try-Catch.</Description>  
<Author>SQL Server Books Online Example</Author>  
<SnippetTypes>  
<SnippetType>SurroundsWith</SnippetType>  
</SnippetTypes>  
</Header>  
<Snippet>  
<Declarations>  
	<Literal>  
		<ID>CatchCode</ID>  
        <ToolTip>Code to handle the caught error</ToolTip>  
        <Default>CatchCode</Default>  
    </Literal>  
</Declarations>  
<Code Language="SQL"><![CDATA[  
SELECT @@VERSION,
SERVERPROPERTY('ProductVersion') as ProductVersion,
SERVERPROPERTY('Edition') as Edition,
SERVERPROPERTY('ProductLevel') as SPStatus
]]>  
</Code>  
</Snippet>  
</CodeSnippet>  
</CodeSnippets>  

Although there is a node called "shortcut", it seems that this functionality has not been implemented, I saw several questions in ST where it is commented.

There are tools that allow to automate this process, some are free, as this:

https://www.apexsql.com/sql-tools-complete.aspx

If you need more information, these links explain in detail how to activate Intellisense and work with snippets:

https://codingsight.com/sql-server-intellisense-and-autocomplete/

https://docs.microsoft.com/en-us/sql/ssms/scripting/add-transact-sql-snippets?view=sql-server-2017

https://www.sqlshack.com/how-to-create-and-manage-t-sql-code-snippets/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.