SQL SERVER 2014 Code Snippets missing

2019-06-24 01:11发布

问题:

I'm trying to use the Snippets functionality in SQL Server.

I'm testing out adding new snippets to SQL Server 2014 following the instruction here.

Everything works fine except that after I added the snippet, it doesn't show up in the IntelliSense. Even more, I realized that not all build-in Snippets are showing up.

I wonder if anyone else has the same experience, and knows how to resolve this?

This is a list of build-in snippets under Function

And this is what I see from IntelliSense (3 of them are missing)

回答1:

The issue is likely in the definition of the snippets.

If you inspect your snippets you should see a section like:

<SnippetTypes>
    <SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>

Or

<SnippetTypes>
    <SnippetType>Expansion</SnippetType>
</SnippetTypes>

These indicate where the snippet can and will be used from.

In a query window you have 2 options when you right click:

  • Insert snippet
  • Surround with

Which give you the different options as you can see here:

This explains why you're not seeing the missing options when you try to insert a snippet.