Snippet Manager - Custom Placeholder
mmosstx
Posts: 1 New member
in SQL Prompt
I have a question, but it's listed at the bottom, want to give an explanation first.
I'm a big fan of using the $PASTE$ placeholder when creating snippets. Typically I use them for Date formatting, example below:
Snippet Code examples:
So with a sample SQL query of
I would cut (CTRL+X) 'abc.Date' and insert the snippet, with 'abc.date' being inserted in the $PASTE$ sections. Example result would be:
It works great, except then I have to go remove the alias from the column name portion.
SO here's my question
Is there a way to create a custom placeholder, that basically works the same way as $PASTE$, but recognizes there's a table alias attached and removes it? i.e.
CONVERT(VARCHAR, $PASTE$, 101) AS $customPASTE$ = CONVERT(VARCHAR, abc.Date, 101) AS Date
I'm a big fan of using the $PASTE$ placeholder when creating snippets. Typically I use them for Date formatting, example below:
Snippet Code examples:
- CONVERT(VARCHAR, $PASTE$, 101) AS $PASTE$
- DATEADD(DAY,1,$PASTE$) AS $PASTE$
So with a sample SQL query of
SELECT abc.Date FROM DB..Alphabet abc
I would cut (CTRL+X) 'abc.Date' and insert the snippet, with 'abc.date' being inserted in the $PASTE$ sections. Example result would be:
SELECT CONVERT(VARCHAR, abc.Date , 101) AS abc.Date FROM DB..Alphabet abc
It works great, except then I have to go remove the alias from the column name portion.
SO here's my question
Is there a way to create a custom placeholder, that basically works the same way as $PASTE$, but recognizes there's a table alias attached and removes it? i.e.
CONVERT(VARCHAR, $PASTE$, 101) AS $customPASTE$ = CONVERT(VARCHAR, abc.Date, 101) AS Date
Tagged:
Answers
Welcome and thanks for contacting us.
Unfortunately, this is currently not possible in Prompt. We only have the $PASTE$ placeholder which inserts the contents of the clipboard without any type of special post-processing or filtering.
I recommend you add a request for this suggestion in our UserVoice forums : https://redgate.uservoice.com/forums/94413-sql-prompt
Kind regards,
Frederico
Redgate Software