December 19, 2016 at 7:27 pm
I've been a huge fan of Snippets for sometime, and I have a bunch of them in a custom folder that I added to my SSMS 2008R2/2012/2014..
However, since I started using SSMS 2016, I'm finding that I have to go into Code Snippets Manager and add my Folder every time.
Has anyone else come across this? or know a way around it?
thanks,
Craig
[font="Tahoma"]"Good is just the beginning" :-)[/font]
December 19, 2016 at 7:43 pm
Have you tried directly adding your folders under:
C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\SQL\Snippets\1033
I would also assume you'd need to include the directory in the XML located in the same directory. Something like:
<SnippetDir>
<OnOff>On</OnOff>
<Installed>true</Installed>
<Locale>LOCALE_ID</Locale>
<DirPath>%InstallRoot%\VSTSDB\Snippets\%LCID%\{Your Folder Name}\</DirPath>
<LocalizedName>View</LocalizedName>
</SnippetDir>
September 27, 2017 at 1:30 am
I use my own snippets since abt. three years now and I can't imagine what a waste a time it would be to work without them. Its frustrating enough to add them on other machines (via a share wherever it is possible) when I can't use my local SSMS.
September 27, 2017 at 5:51 am
SQLvis - Monday, December 19, 2016 7:43 PMHave you tried directly adding your folders under:C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\SQL\Snippets\1033I would also assume you'd need to include the directory in the XML located in the same directory. Something like:<SnippetDir> <OnOff>On</OnOff> <Installed>true</Installed> <Locale>LOCALE_ID</Locale> <DirPath>%InstallRoot%\VSTSDB\Snippets\%LCID%\{Your Folder Name}\</DirPath> <LocalizedName>View</LocalizedName> </SnippetDir>
9 mo's old but I just saw this...
No change is necessary to the snippet.
-- Itzik Ben-Gan 2001
September 27, 2017 at 9:24 am
Thanks, nice article. it is always helpful to me.
I keep my mostly used queries in the folder in "Template Browser", that is easier way to access.
September 27, 2017 at 12:12 pm
Thanks Avi1 that is alot easier than messing around with snippet folders.
August 17, 2018 at 4:15 am
ApexSQL complete offers THE best support for code snippets. It has support for creating code snippets directly in SQL (without need to mess around with XML), bind them to keywords and include them in suggestions while you're typing. And it's free.
August 17, 2018 at 6:49 am
Luis, we put ours in a shared folder on the common drive and then have everyone point their Code Snippet Manager there, so that if someone adds a new one we all get the use of it. I'm not sure how many team members are actually taking advantage of it, but I do regularly. I've even used it to enforce the documentation standards, by creating a snippet for blank scripts/SPs that includes most of the things we look for in QA, and some commented-out reminders for things like adding extended properties and unit tests.
Also snippets for things like querying all of the servers we use regularly, so you don't have to remember full names, etc.
You can do a lot with snippets very fast, if you put some thought into how to use them best for your situation.
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
August 17, 2018 at 7:09 am
bojned - Friday, August 17, 2018 4:15 AMApexSQL complete offers THE best support for code snippets. It has support for creating code snippets directly in SQL (without need to mess around with XML), bind them to keywords and include them in suggestions while you're typing. And it's free.
Thank you for sharing. I used to have ApexSQL software in my previous job and it worked nicely. However, this solution is for those poor guys that aren't able to install "unauthorized" software in their machines.
August 17, 2018 at 7:10 am
jonathan.crawford - Friday, August 17, 2018 6:49 AMLuis, we put ours in a shared folder on the common drive and then have everyone point their Code Snippet Manager there, so that if someone adds a new one we all get the use of it. I'm not sure how many team members are actually taking advantage of it, but I do regularly. I've even used it to enforce the documentation standards, by creating a snippet for blank scripts/SPs that includes most of the things we look for in QA, and some commented-out reminders for things like adding extended properties and unit tests.Also snippets for things like querying all of the servers we use regularly, so you don't have to remember full names, etc.
You can do a lot with snippets very fast, if you put some thought into how to use them best for your situation.
That's a great idea. It's great to learn about teams working together and sharing tools.
August 17, 2018 at 7:31 am
Great article thanks!!
In case someone wants to share thos esnippets, here's a tool can could be handy: https://www.snip2code.com
It is a snippet repository with more than 3 millions of snippets created by the community.
August 20, 2018 at 6:39 am
Hi
Very good article.
Immediatly after reading it i tried creating my fist snippet that I dreamt of for years:
An "Encapsulate" snippet.
So my first snippet was SUM as in SUM(field)
Great
Then my ballon exploded when I tried to create my second SUMAS snippet. Boo boo boo. Cannot be done.
I wanted a SUM(field) AS field snippet. SSMS does not let you put $selected$ twice in the snipet. So that kind of encapsulation snippet cannot be accomplished.
I would have loved to create SUMAS, ISNULLAS, CONVERTAS snippet. Cannot be done.
It is a shame that Microsoft does not let you put $selected$ more than once in a snippet.
But still ...it is very usefulle for other use
thanks
August 20, 2018 at 6:51 am
mtrudel337 - Monday, August 20, 2018 6:39 AMHi
Very good article.
Immediatly after reading it i tried creating my fist snippet that I dreamt of for years:
An "Encapsulate" snippet.
So my first snippet was SUM as in SUM(field)
Great
Then my ballon exploded when I tried to create my second SUMAS snippet. Boo boo boo. Cannot be done.
I wanted a SUM(field) AS field snippet. SSMS does not let you put $selected$ twice in the snipet. So that kind of encapsulation snippet cannot be accomplished.
I would have loved to create SUMAS, ISNULLAS, CONVERTAS snippet. Cannot be done.
It is a shame that Microsoft does not let you put $selected$ more than once in a snippet.But still ...it is very usefulle for other use
thanks
maybe try using $selected$ as a string literal in the declarations, then use that variable instead
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
August 20, 2018 at 7:27 am
mtrudel337 - Monday, August 20, 2018 6:39 AMHi
Very good article.
Immediatly after reading it i tried creating my fist snippet that I dreamt of for years:
An "Encapsulate" snippet.
So my first snippet was SUM as in SUM(field)
Great
Then my ballon exploded when I tried to create my second SUMAS snippet. Boo boo boo. Cannot be done.
I wanted a SUM(field) AS field snippet. SSMS does not let you put $selected$ twice in the snipet. So that kind of encapsulation snippet cannot be accomplished.
I would have loved to create SUMAS, ISNULLAS, CONVERTAS snippet. Cannot be done.
It is a shame that Microsoft does not let you put $selected$ more than once in a snippet.But still ...it is very usefulle for other use
thanks
You could change your approach. Instead of using a Surround With snippet, use an Expansion one. If you already have the column, copy or cut it, insert the snippet while replacing the column and paste the column on the literal. Something like this:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>SUM AS</Title>
<Shortcut></Shortcut>
<Description>Add SUM() and alias to a column</Description>
<Author>Luis C</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>ColumnName</ID>
<ToolTip>Name of the column</ToolTip>
<Default>ColumnName</Default>
</Literal>
</Declarations>
<Code Language="SQL">
<![CDATA[SUM( $ColumnName$) AS $ColumnName$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
August 20, 2018 at 11:34 am
Need the extra step of doing a copy-text first but works perfectly
Thank you
Viewing 15 posts - 16 through 30 (of 34 total)
You must be logged in to reply to this topic. Login to reply