mercredi 28 janvier 2015

How to format T-SQL identifiers in camel case


A number of tools exist which are designed to facilitate formatting the T-SQL in an inherited script or stored procedure to match one's personal preferences.


One feature I would like to see in such a tool is the ability to convert the name of any object or column to camel case, regardless of the case in which it originally appears. For example, I would like to be able to end up with AnObjectNamedLikeThis no matter whether it started out as anobjectnamedlikethis, ANOBJECTNAMEDLIKETHIS, or in some other permutation of mixed case.


I understand that it would be impossible or impractical to algorithmically determine the correct way to refactor a given identifier; however, I can't imagine it would be too difficult to match one by its spelling against an entry in a custom dictionary, and substitute a replacement value in camel case for the original string. It would be tedious, but not overwhelmingly so, to produce a custom dictionary by exporting and editing the results of queries against the appropriate system tables such as sys.objects and sys.columns.


Has anyone accomplished this, either in an SSMS addin I'm unaware of or through some standalone text editor? Mladen Prajdic's SSMS Tools Pack purports to offer the feature, but I have only been able to get it work under certain circumstances, such as when a object name is not fully qualified. I also attempted it using a custom dictionary in an older version of TextPad (4.7.3), to little avail.


Am I missing anything?





Aucun commentaire:

Enregistrer un commentaire