Database-specific snippets
Database-specific snippets.
We have 80 or so databases scattered across 200+ instances and many tables have similar names or identical names with differing schemas: compare person.personpe, dbo.person & finance.personpe. This particular is extreme and there are more examples but the principle applies.
I would love to be able to define pe as a snippet at a database level so that I can keep my snippet names short and so that I don't have to rename them manually when I am in SSMS with a lesser used database.
-
Sean Redmond commented
Auto-completion is what I use at the moment but it distracts from the power of snippets. With snippets I am able to type in, say, pe and dbo.persons comes up but this becomes a problem when I am using those databases that I venture less frequently into.
The auto-complete is good but it slows me down in that I have to consider what the correct variant that I want is.
If snippets could be made database-dependent, then I could simply define one set of snippets per database and then not have to think about whether I have the right persons table or not. -
Sean Redmond commented
This is true.
At the moment, auto-completion has become useful but it means that the snippets are relegated in importance. They only useful in the databases whose snippets I have defined and I have to constantly think about similarly named tables from other databases.
The snippets are fast though and I don't think that it would be that great a change to introduce this change. One would need a tree structure in the snippets folder and code to tell SQL Prompt which leaf folder to use. -
Thomas Franz commented
Shouldn't the auto completion suggests the person table as soon you are typing pe after a FROM / JOIN etc.?
And even if you have multiple pe%-tables, it is selflearning, so you just need to pick up the correct table once (per day / SSMS-restart) and it will be the top suggestion the next time.