Using Code Snippets in SSMS

  • Luis Cazares - Wednesday, April 6, 2016 11:36 PM

    Comments posted to this topic are about the item Using Code Snippets in SSMS

    Wow, followed all the steps, I think. but SSMS doesn't see my custom snippets.

  • Hi

    Anyway to create a surround snippet  for a SQL function like SUM(), CONVERT(), ISNULL() with AS Field at the end

    SUM(MyField) AS MyField ?

    It is not possible to include $selected$ twice in a snippet code as in:

    Code Language="SQL"><![CDATA[SUM($selected) AS $selected$]]>

    Do you know another way ?

    I tried many SSMS addons. None is able to do this 🙁

     

     

  • This is great article!  I'm going to give it a try.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • mtrudel337 wrote:

    Hi

    Anyway to create a surround snippet  for a SQL function like SUM(), CONVERT(), ISNULL() with AS Field at the end

    SUM(MyField) AS MyField ?

    It is not possible to include $selected$ twice in a snippet code as in:

    Code Language="SQL"><![CDATA[SUM($selected) AS $selected$]]>

    Do you know another way ?

    I tried many SSMS addons. None is able to do this 🙁

     

    There's an alternative with an extra step that might work a few comments back.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Yeah, I think Luis' suggestion of making it an expansion template is the way to go. There may be a way to make it work using XSLT, but that seems like overkill, and I'm not sure it's really any easier.

    I tried declaring a variable and populating it with the $selected$ value, but it still won't work. Doesn't recognize the placeholder in the Declarations, even if I use the CDATA tags, and only drops the value in as a replaceable field instead of actually putting the value in.

    -------------------------------------------------------------------------------------------------------------------------------------
    Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses

Viewing 5 posts - 31 through 34 (of 34 total)

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